Categories
不学无术

MFC开启/关闭数字键盘(小键盘)

呵呵呵呵,帮别人改程序,然后自己的x230没有找到任何开启/关闭小键盘的方法。MFC程序运行发现小键盘默认开启的,导致我+-号键用不来。

// Set NUMLOCK Status.
void SetNumLock( BOOL bState )
{
    BYTE keyState[256];
    GetKeyboardState((LPBYTE)&keyState);
    if( (bState && !(keyState[VK_NUMLOCK] & 1)) ||
        (!bState && (keyState[VK_NUMLOCK] & 1)) )
    {
        // Simulate a key press
        keybd_event( VK_NUMLOCK,
                     0x45,
                     KEYEVENTF_EXTENDEDKEY | 0,
                     0 );
        // Simulate a key release
        keybd_event( VK_NUMLOCK,
                     0x45,
                     KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP,
                     0);
    }
}

来自http://weseetips.com/tag/enable-numlock/

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.