怎么实现鼠标移到位图按钮上时,位图按钮变大,移开后又恢复原样

解决方案 »

  1.   

    mouseover 时放大,mouseleave 时 还原
      

  2.   

    呵呵,具体怎样实现呢,我是用位图按钮CBitmapButton 类派生的类试的,刚开始用LoadBitmap加载一副位图,然后当鼠标移上去时换一个大的位图,不过这样运行时总会出错,难道是一个按钮加载两幅位图发生冲突放大的话,可以直接放大吗?可以提供下具体思路吗?
      

  3.   

    void MyButton::OnMouseMove(UINT nFlags, CPoint point)
    {
    if(!m_tracking)
    {
    TRACKMOUSEEVENT tme;
    tme.cbSize = sizeof(tme);
    tme.dwFlags = TME_HOVER|TME_LEAVE;
    tme.dwHoverTime =1;
    tme.hwndTrack = m_hWnd;
    m_tracking = _TrackMouseEvent(&tme);
    }
    //
    #if 1
    if(MK_LBUTTON==nFlags)
    {
    CRect rc;
    GetClientRect(&rc);
    MapWindowPoints(GetParent(),&rc);
    MapWindowPoints(GetParent(),&point,1);
    MoveWindow(point.x-m_MouseLast.x, point.y-m_MouseLast.y, rc.Width(), rc.Height());
    }
    #endif 
    // CButton::OnMouseMove(nFlags, point);
    }
    //
    LRESULT MyButton::OnMouseLeave(WPARAM wParam, LPARAM lParam)
    {
    //afxDump << "leave\n" ;
    m_tracking = FALSE;
    m_hover = false;
    Invalidate();
    return 0;
    }
    //
    LRESULT MyButton::OnMouseHover(WPARAM wParam, LPARAM lParam)
    {
    //afxDump << "hover\n" ;
    m_hover = true;
    Invalidate();
    m_tracking = FALSE;
    return 0;
    }