simple article about how to use ON_WM_MOUSELEAVE leave on a button.
The button has to track the mouse while moues move (ON_WM_MOUSEMOVE) is called.
void CMYButton::OnMouseMove(UINT nFlags, CPoint point)
{
if (!m_bTracking)
{
TRACKMOUSEEVENT tme;
tme.cbSize = sizeof(tme);
tme.hwndTrack = m_hWnd;
tme.dwFlags = TME_LEAVE|TME_HOVER;
tme.dwHoverTime = 1;
m_bTracking = _TrackMouseEvent(&tme);
m_point = point;
}
LRESULT CMYButton::OnMouseHover(WPARAM wparam, LPARAM lparam)
{
m_txtInfo->SetWindowText(m_strInformation);
return m_bTracking;
}
LRESULT CMYButton::OnMouseLeave(WPARAM wparam,LPARAM lparam)
{
m_txtInfo->SetWindowText("");
m_bTracking = FALSE;
return 0;
}
Source:
https://microsoft.public.vc.mfc.narkive.com/YBQSIfWf/on-mouseleave-and-cbutton-with-windows-xp-desktop-theme