如何确定键盘上同时按下了两个健,
如shift + UP ,shift + c ,
onKeyDown好像不行
因为按下第二个健以后第一个建的事件就终止了

解决方案 »

  1.   

    设个变量:bool bIsShiftDown=false;
    当按shift键OnKeyDown时将bIsShiftDown=true;
    相反OnKeyUp时bIsShiftDown=false;
    然后在按别的键时判断上面的值就知道是否为按下状态了。
      

  2.   

    正宗一点的方式:
    使用函数GetKeyState()或GetKeyboardState()。MSDN有详细说明。
    if(::GetKeyState(VK_LSHIFT)<0)
        MessageBox("shift key is down");
      

  3.   

    判断有了shift时是否还有别的
      

  4.   

    一个道理
    GetKeyState()或GetKeyboardState()。
      

  5.   

    OnChar()可以判断是否按下等
    CWnd::OnChar
    afx_msg void OnChar( UINT nChar, UINT nRepCnt, UINT nFlags );ParametersnCharContains the character code value of the key.nRepCntContains the repeat count, the number of times the keystroke is repeated when user holds down the key.nFlagsContains the scan code, key-transition code, previous key state, and context code, as shown in the following list:Value Meaning 
    0-15 Specifies the repeat count. The value is the number of times the keystroke is repeated as a result of the user holding down the key. 
    16-23 Specifies the scan code. The value depends on the original equipment manufacturer (OEM) 
    24 Specifies whether the key is an extended key, such as the right-hand ALT and CTRL keys that appear on an enhanced 101- or 102-key keyboard. The value is 1 if it is an extended key; otherwise, it is 0. 
    25-28 Used internally by Windows. 
    29 Specifies the context code. The value is 1 if the ALT key is held down while the key is pressed; otherwise, the value is 0. 
    30 Specifies the previous key state. The value is 1 if the key is down before the message is sent, or it is 0 if the key is up. 
    31 Specifies the transition state. The value is 1 if the key is being released, or it is 0 if the key is being pressed. 
      

  6.   

    BOOL CMyFormView::PreTranslateMessage(MSG* pMsg) 
    {
    BOOL bShiftDown=::GetKeyState(VK_SHIFT)&0x8000;// if (pMsg->message==WM_KEYDOWN && !bShiftDown) {
    // pMsg->hwnd=NULL; return TRUE;} return CFormView::PreTranslateMessage(pMsg);
    }
      

  7.   

    BOOL bUpDown=::GetKeyState(VK_UP)&0x8000;