重载CStatic类,在鼠标入入事件中添加
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
tme.hwndTrack = m_hWnd;
tme.dwFlags = TME_LEAVE | TME_HOVER;
tme.dwHoverTime = 1;
_TrackMouseEvent(&tme);
则会接收到鼠标离开事件。
BEGIN_MESSAGE_MAP(CMyStatic, CStatic)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_MOUSEMOVE,mv)
ON_MESSAGE(WM_MOUSEHOVER,mho)
ON_MESSAGE(WM_MOUSELEAVE,ml)
ON_MESSAGE(WM_MOUSEFIRST,mf)
END_MESSAGE_MAP()
需要重写CSTATIC类!~