VC6.0编程,要求知道目前用户是否按下Shift,若按下OnDraw()显示有变化。查MSDN上WIN32 SDK有这么一个系统调用GetKeyState(VK_LSHIFT/VK_RSHIFT/VK_SHIFT)
但是它返回的是SHORT,MSDN上这么说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. 我不知道如何写判读语句,大虾指点
但是它返回的是SHORT,MSDN上这么说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. 我不知道如何写判读语句,大虾指点
if(::GetKeyState(VK_CONTROL) < 0)
{
...
}
PreTranslateMessage(MSG* pMsg)函数里判断:
if(::GetKeyState(VK_SHIFT) < 0)
{
...
}
if(pMsg->message ==WM_KEYDOWN&&pMsg->wParam==VK_F1 &&GetKeyState(VK_CONTROL)&0x80)
PreTranslateMessage()中加入
if(::GetKeyState(VK_SHIFT) < 0)
{
....
Invalidate();
}
int nVirtKey // virtual-key code
);
VK_LSHIFTVK_RSHIFT
{
short sKey = GetKeyState(VK_SHIFT);
if( ((sKey & 0x0080) != 0) && (nChar == VK_F10) )
{
}
}
if(GetKeyState(VK_SHIFT) & 0x80)
{
AfxMessageBox("Shift Down!");
}
{
if( pMsg->message == WM_KEYDOWN )
{
switch( pMsg->wParam )
{
case VK_RETURN:
//组合键
if(::GetKeyState(VK_CONTROL) < 0)//Shift+enter
{
//你的处理
}
}
}
return CDialog::PreTranslateMessage(pMsg);
}