也就是鼠标移到哪,按扭跟到哪,谢谢

解决方案 »

  1.   

    一个无法下按的按钮(按钮跟着鼠标移动) - Chris Maunder (1998/08/11) http://www.vckbase.com/english/code/buttonctrl/trick_button.shtml.htm
      

  2.   

    将鼠标按下时的鼠标移动的参数作为MoveWindow函数的参数。
      

  3.   

    syy64(太平洋) :我试过了,鼠标按在按扭上时,容纳按扭的窗口收不到buttondown,mousemove的消息
      

  4.   

    Call this member function to change the size, position, and Z-order of child, pop-up, and top-level windows. 
    BOOL SetWindowPos(
       const CWnd* pWndInsertAfter,
       int x,
       int y,
       int cx,
       int cy,
       UINT nFlags 
    );
     
    这个也可以~~~
      

  5.   

    kikikind(可乐):感谢回答,但我问的不是这个问题,
      

  6.   

    从CButton类继承自己的按钮类CMyButton
    加入三个成员变量: BOOL m_bCapture;
    CPoint m_pt;
    CRect m_rect;然后映射WM_LBUTTONDOWN/WM_LBUTTONUP/WM_MOUSEMOVE消息,象下面这样就可以了.
    void CMyButton::OnMouseMove(UINT nFlags, CPoint point) 
    {
    // TODO: Add your message handler code here and/or call default
    CButton::OnMouseMove(nFlags, point);
    if (!m_bCapture) return;

    ClientToScreen(&point);
    int x=point.x-m_pt.x+m_rect.left;
    int y=point.y-m_pt.y+m_rect.top; CRect rect(x,y,x+m_rect.Width(),y+m_rect.Height());

    MoveWindow(&rect);
    }void CMyButton::OnLButtonDown(UINT nFlags, CPoint point) 
    {
    // TODO: Add your message handler code here and/or call default
    CButton::OnLButtonDown(nFlags, point);
    SetCapture();
    m_bCapture=TRUE;
    m_pt=point;

    ClientToScreen(&m_pt);
    GetWindowRect(&m_rect);
    GetParent()->ScreenToClient(&m_rect);
    }void CMyButton::OnLButtonUp(UINT nFlags, CPoint point) 
    {
    // TODO: Add your message handler code here and/or call default
    CButton::OnLButtonUp(nFlags, point);
    ReleaseCapture();
    m_bCapture=FALSE;
    }