如何判断用户鼠标点击选中时,是否按住Shift

解决方案 »

  1.   

    http://community.csdn.net/Expert/topic/3177/3177935.xml?temp=7.368106E-02
      

  2.   

    CWnd::OnLButtonDown
    afx_msg void OnLButtonDown( UINT nFlags, CPoint point );ParametersnFlagsIndicates whether various virtual keys are down. This parameter can be any combination of the following values: MK_CONTROL   Set if the CTRL key is down.
    MK_LBUTTON   Set if the left mouse button is down.
    MK_MBUTTON   Set if the middle mouse button is down.
    MK_RBUTTON   Set if the right mouse button is down.
    MK_SHIFT   Set if the SHIFT key is down. 
    pointSpecifies the x- and y-coordinate of the cursor. These coordinates are always relative to the upper-left corner of the window.
      

  3.   

    if(nFlags == MK_SHIFT)
     MessageBox("shift key is down");
      

  4.   


    if(nFlags&MK_SHIFT)// 用 位操作  &
      

  5.   

    判断高位
    if(GetKeyState(VK_SHIFT) & 0x80) 
    {
        SetCursor(m_hCursorZoomOut);// 按下
    }
    else
    {
        SetCursor(m_hCursorZoomIn); // 放开
    }
      

  6.   

    BOOL CTest6Dlg::PreTranslateMessage(MSG* pMsg) 
    {
    if( pMsg->message == WM_LBUTTONDOWN )

    if(pMsg->hwnd == GetDlgItem(IDC_EDIT1)->m_hWnd)
    {
      if(::GetKeyState(VK_SHIFT) < 0)
      {
    AfxMessageBox("按下shift");   
      }
      else
      AfxMessageBox("未按下shift");
      return TRUE;
    }
    }
    return CDialog::PreTranslateMessage(pMsg);
    }