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.    我不知道如何写判读语句,大虾指点

解决方案 »

  1.   

    PreTranslateMessage(MSG* pMsg)函数里判断:
    if(::GetKeyState(VK_CONTROL) < 0)

    ...
      

  2.   

    笔误:
    PreTranslateMessage(MSG* pMsg)函数里判断:
    if(::GetKeyState(VK_SHIFT) < 0)
    {
    ...
    }
      

  3.   

    比如CTRL+F1在PreTranslateMessage()中如何取得?
    if(pMsg->message ==WM_KEYDOWN&&pMsg->wParam==VK_F1 &&GetKeyState(VK_CONTROL)&0x80)
      

  4.   

    来迟了
    PreTranslateMessage()中加入
    if(::GetKeyState(VK_SHIFT) < 0)
    {
       ....
       Invalidate();
    }
      

  5.   

    SHORT GetKeyState(
      int nVirtKey   // virtual-key code
    );
    VK_LSHIFTVK_RSHIFT
      

  6.   

    SHIFT || CONTROL 属于系统键//Catch shift + F10 virtual keyvoid CXX::OnSysKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
    {
    short sKey = GetKeyState(VK_SHIFT);
    if( ((sKey & 0x0080) != 0) && (nChar == VK_F10) )
             {
             }
    }
      

  7.   

    得到状态后测试最高位
    if(GetKeyState(VK_SHIFT) & 0x80)
    {
         AfxMessageBox("Shift Down!");
    }
      

  8.   

    BOOL CTest6Dlg::PreTranslateMessage(MSG* pMsg) 
    {
    if( pMsg->message == WM_KEYDOWN )
    {        
    switch( pMsg->wParam )
    {
    case VK_RETURN:

      //组合键
      if(::GetKeyState(VK_CONTROL) < 0)//Shift+enter
      {
            //你的处理
      }

    }
    }
    return CDialog::PreTranslateMessage(pMsg);
    }
      

  9.   

    多谢 holyeagle(一杯清茶) 大虾指点:)