首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > VC/MFC >

怎样判断当前CTRL键被按下,小弟我说的是当前

2012-03-02 
怎样判断当前CTRL键被按下,我说的是当前。我使用了GetAsyncKeyState(VK_CONTROL)0和#defineIsCTRLpressed(

怎样判断当前CTRL键被按下,我说的是当前。
我使用了GetAsyncKeyState(VK_CONTROL)       <       0   和
#define       IsCTRLpressed()           (       (GetKeyState(VK_CONTROL)       &       (1       < <       (sizeof(SHORT)*8-1)))       !=       0       )
进行判断,但是当我在需要判断之前按了一下CTRL后又松开,然后判断,发现以上函数表示的是CTRL已经被按下,但实际上我已经松开了,但如果再判断一次的话又会正常,为什么?

[解决办法]
PreTranslateMessage
[解决办法]
捕捉窗口的PreTranslateMessage
BOOL CMyWnd::PreTranslateMessage(MSG* pMsg)
{
// Catch the Alt key so we don 't choke if focus is going to an owner drawn button
if (pMsg-> message == WM_SYSCHAR)
return TRUE;
//int aa;
if(pMsg-> message == WM_KEYDOWN)
{
if (pMsg-> wParam == VK_CONTROL)
{

return TRUE;
}
}
}
[解决办法]
The GetAsyncKeyState function determines whether a key is up or down at the time the function is called, and whether the key was pressed after a previous call to GetAsyncKeyState.
因为Async。

使用GetKeyState或者GetKeyboardState

热点排行