我在捕获按钮上的OnMouseMove事件,但当按钮可用是就不行捕获是怎么回事,该如何做?

解决方案 »

  1.   

    void CGraphView::OnMouseMove(UINT nFlags, CPoint point) 
    {
    CScrollView::OnMouseMove(nFlags, point); CClientDC dc(this);
    OnPrepareDC(&dc);
    dc.DPtoLP(&point);
        center=wrect.CenterPoint();
        if ( sizingcircle )
    {
    InvalidateRect(wrect,FALSE);
        int bj=len(point,center);
    wj=bj;
            //wrect.SetRect(center.x-bj,center.y-bj,center.x+bj,center.y+bj);
            wrect.SetRect(center.x-wj,center.y-wj,center.x+wj,center.y+wj);
      }
        if ( movingcircle )
    {
    InvalidateRect(wrect,FALSE);
        wrect.OffsetRect(point-movefrompoint);
            movefrompoint.x=point.x;
        movefrompoint.y=point.y;
    }
    center=wrect.CenterPoint();
        if(bmploaded && len(center,point)<(int)((nrect.Height()-1)/2+1))
    {
             ::SetCursor(::LoadCursor(NULL,IDC_SIZEALL));
        canmovecircle=TRUE;
    SetCapture();
    }
    else if(canmovecircle)

    canmovecircle=FALSE;
    ReleaseCapture();
    }    if(bmploaded && abs(len(center,point)-wrect.Height()/2)<3)
    {
    if(abs(point.x-center.x)>abs(point.y-center.y))
    ::SetCursor(::LoadCursor(NULL,IDC_SIZEWE));
        else
    ::SetCursor(::LoadCursor(NULL,IDC_SIZENS));
    cansizecircle=TRUE;
    SetCapture();
    }
    else if(cansizecircle)
    {
    cansizecircle=FALSE;
    ReleaseCapture();
    }
        
    SetCursor(point);//调用设置游标函数
    }
    对照一下吧!
      

  2.   

    一个button也是一个窗口,它有它自己的窗口类(类名称为"BUTTON")和它自己的窗口过程,普通的WM_xxxx类型的消息都由它自己的窗口过程处理了,所以你不能截获这些消息。
    要截获这些消息需要subclass一个button窗口,即修改这个窗口的窗口过程,使它指向你自己定义的窗口过程,在自己定义的窗口过程中处理要截获的消息,当然把不打算截获的消息发送给缺省的窗口过程。以上只是一些理论性的提示。SDK中和MFC中都可以实现BUTTON的subclass。请参见MSDN。
      

  3.   

    重載CBUTTON
    軟後添加他的WM_MOUSEMOVE事件..在那理處理