移除事件是要用_TrackMouseEvent函数注册的,
_TrackMouseEvent注册一次,会响应一次,所以不能注册多了,
响应的消息宏也是固定的,必须为WM_MOUSELEAVE
if(!m_bOverTab )
{// We are here if the mouse just entered the CLBTabCtrl
//
// Let's use _TrackMouseEvent API to be notified when the mouse leaves.
// This API tries to use the window manager's
// implementation of TrackMouseEvent if it is present,
// otherwise it emulates.
m_bOverTab=true;
TRACKMOUSEEVENT stTRACKMOUSEEVENT;
stTRACKMOUSEEVENT.cbSize = sizeof(stTRACKMOUSEEVENT);
stTRACKMOUSEEVENT.hwndTrack=m_hWnd;
stTRACKMOUSEEVENT.dwFlags=TME_LEAVE;
_TrackMouseEvent(&stTRACKMOUSEEVENT);
Invalidate();
}
添加消息
ON_MESSAGE(WM_MOUSELEAVE,OnMouseLeave)
函数原型
afx_msg LRESULT OnMouseLeave(WPARAM, LPARAM);
函数定义:
LRESULT CMyTabCtrl::OnMouseLeave(WPARAM, LPARAM)
{
Invalidate();
m_bOverTab=false;
return 0;
}