alt鍵會阻斷消息? moousemove
alt鍵無法判斷,按下一次 並松開一次狀態改變一次
#define KeyState GetAsyncKeyState
BOOL bCtrlDown = (KeyState(VK_CONTROL) & 0xff00) > 0 ? TRUE : FALSE;//81 80
BOOL bShiftDown = (KeyState(VK_SHIFT) & 0xff00) > 0 ? TRUE : FALSE;//81 80
BOOL bAltDown = (KeyState(VK_MENU) & 0xff00) > 0 ? TRUE : FALSE;//81 80
CString str;
CString csCtrl;
CString csAlt;
CString csShift;
csCtrl = bCtrlDown == TRUE ? _T("TRUE") : _T("FALSE");
csShift = bShift == TRUE ? _T("TRUE") : _T("FALSE");
csAlt = bAlt == TRUE ? _T("TRUE") : _T("FALSE");
CString cstr;
cstr.Format(_T("Ctrl:%d,Shift:%d,Alt:%d"), bCtrlDown, bShiftDown, bAltDown);
txt2.SetWindowText(cstr);
keydown按鍵觸發
void CKeyDownTestDlg::OnKeyDown(WPARAM wparam)
{
bool bDownValue = true;
if (wparam == VK_CONTROL || wparam == VK_LCONTROL)
{
bCtrl = bDownValue;
}
//這個響應不及時,需要WM_SYSKEYDOWN才能響應
if (wparam == VK_MENU || wparam == VK_LMENU || wparam == VK_RMENU)
{
bAlt = bDownValue;
}
if (wparam == VK_SHIFT || wparam == VK_LSHIFT)
{
bShift = bDownValue;
}
Update();
}