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.举个例子吧..3Q.
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.举个例子吧..3Q.
else if(pMsg->message == WM_LBUTTONDOWN)
{
if(GetAsyncKeyState(VK_LCONTROL) & 0x8000)
m_DownKey=1;//LCONTROL
else if (GetAsyncKeyState(VK_RCONTROL) & 0x8000)
m_DownKey=2;//RCONTROL
else if (GetAsyncKeyState(VK_LSHIFT) & 0x8000)
m_DownKey=3;//LSHIFT
else if (GetAsyncKeyState(VK_RSHIFT) & 0x8000)
m_DownKey=4;//RSHIFT
else if (GetAsyncKeyState(VK_LMENU) & 0x8000)
m_DownKey=5;//LALT
else if (GetAsyncKeyState(VK_RSHIFT) & 0x8000)
m_DownKey=6;//RALT
else
m_DownKey=0;//none
BOOL CEDlg::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(WM_KEYDOWN == pMsg->message && _T('C') == pMsg->wParam)
{
if(HIBYTE(GetKeyState(VK_CONTROL)))
{
AfxMessageBox(_T("You press key: Ctrl + C!"));
}
}
return CDialog::PreTranslateMessage(pMsg);
}