我的系统是xpsp3的,
我像通过GetAsyncKeyState判断键盘弹起,如下,BOOL CMyDlg::PreTranslateMessage(MSG* pMsg) 
{
SHORT aa= GetAsyncKeyState(VK_SHIFT);
SHORT bb = aa&0x8000;
if (aa && !bb)
{
return TRUE;
} return CDialog::PreTranslateMessage(pMsg);
}我在return TRUE;这里下断点,
网上好像普遍都是if(bb),我测试的时候这样即使不按任何键也都会断下,
然后我试着用if (aa && !bb),但是根本就断不下来,
有没有人知道为什么?

解决方案 »

  1.   

    if(GetAsyncKeyState(VK_SHIFT))
    {
    ……
    }if(pMsg->message == WM_KEYUP)
    {
    }使用GetAsyncKeyState之后,也无法捕获到WM_KEYUP消息了,
    ??????
      

  2.   

    if(GetKeyState(VK_SHIFT) & 0x80)
    {
     ....
    }
      

  3.   

    不行,我在我电脑上测试过了,
    GetKeyState跟GetAsyncKeyState效果一样,不能判断按键弹起,
    这是关于GetKeyState的msdn返回值说明,Return Values
    The return value specifies the status of the specified virtual key, as follows: If the high-order bit is 1, the key is down; otherwise, it is up. 
    If the low-order bit is 1, the key is toggled. A key, such as the CAPS LOCK key, is toggled if it is turned on. The key is off and untoggled if the low-order bit is 0. A toggle key's indicator light (if any) on the keyboard will be on when the key is toggled, and off when the key is untoggled.