15,979
社区成员
发帖
与我相关
我的任务
分享
void MyButton::OnLButtonDown(UINT nFlags, CPoint point)
{
// transform left-top to point
CRect rc;
GetClientRect(&rc);
MapWindowPoints(GetParent(),&rc);
MapWindowPoints(GetParent(),&point,1);
m_MouseLast.x=point.x-rc.left;
m_MouseLast.y=point.y-rc.top;
// afxDump << m_MouseLast << "\n";
//
CButton::OnLButtonDown(nFlags, point);
}
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
}
LRESULT MyButton::OnMouseLeave(WPARAM wParam, LPARAM lParam)
{
//afxDump << "leave\n" ;
if(m_hover)
{
m_hover = false;
m_tracking = FALSE;
Invalidate();
}
return 0;
}
//
LRESULT MyButton::OnMouseHover(WPARAM wParam, LPARAM lParam)
{
//afxDump << "hover\n" ;
if(!m_hover)
{
m_hover = true;
m_tracking = FALSE;
Invalidate();
}
return 0;
}