There are two ways.
The first is to use WM_TIMER, where the mouse is inspected, but the efficiency is relatively low, it is not recommended.
The second is to use TrackMouseevent. Recommended. Specific Usage Reference MSDN
TRACKMOUSEEVENT; Event.cbsize = sizeof (event); event.dwflags = tme_leave; event.dwhovertime = 0; Event.hwndtrack = getsafehwnd (); verify (_trackmounteevent (& evevent));
Note Add WM_MOUSELEAVE message processing
Lresult Cstatlist :: OnMouseLeave (WPARAM WPARAM, LPARAM LPARAM) {RRRETURN 0;}
ON_MESSAGE (WM_MOUSELEAVE, ONMOUSELEAVE)
AFX_MSG LRESULT ONMOUSELEAVE (WPARAM WPARAM, LPARAM LPARAM);