OnMouseMove 和 OnLButtonDown 两个消息是怎么相关的啊, 我现在需要判断 按下鼠标左键移动鼠标这个事件,怎么捕获? 在那个函数里,还是两个组合着用?

解决方案 »

  1.   

    楼上正解OnMouseMove 和 OnLButtonDown 没关系吧鼠标按一下是响应了两个消息
    OnLButtonDown和OnLButtonUp
      

  2.   

    响应OnMouseMoveCWnd::OnMouseMove  
    afx_msg void OnMouseMove( 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. 
    ========================================
    看到了吧,然后判断nFlags中是否包含MK_LBUTTON属性在里面。
      

  3.   

    我刚做好了一个类似于3ds max的拖动的面板,也用到了,void CMyDlg::OnLButtonDown(UINT nFlags, CPoint point) 
    {
    // TODO: Add your message handler code here and/or call default
    SetCapture();
    m_mousePoint = point;
    ::SetCursor(AfxGetApp()->LoadCursor (IDC_CURSOR_HAND));
    CDialog ::OnLButtonDown(nFlags, point);
    }void CMyDlg::OnLButtonUp(UINT nFlags, CPoint point) 
    {
    // TODO: Add your message handler code here and/or call default
    ReleaseCapture();
    CDialog ::OnLButtonUp(nFlags, point);
    }void CMyDlg::OnMouseMove(UINT nFlags, CPoint point) 
    {
    // TODO: Add your message handler code here and/or call default
    if (MK_LBUTTON == nFlags)
    {
                 //mouse move  && LButtonDown
    }
    CDialog ::OnMouseMove(nFlags, point);
    }