By default, the window does not respond to the wm_mouseleave and wm_mousehover messages. Therefore, use the _ trackmouseevent function to activate the two messages. After this function is called, when the mouse stays in the specified window for more than a certain period of time or leaves the window, the function will post the two messages to the specified window.
Usage:
1. Define a variable in the window class to identify whether to track the current mouse state. The reason for this definition is to avoid repeated wm_mousehover when the mouse is already on the form.
Bool_ Bmousetrack =True;
2. Call in onmousemove _ Trackmouseevent Function
If (_ bmousetrack) // If allowedTrace, then.
{
Trackmouseevent Cstme;
Cstme. cbsize =Sizeof (Cstme );
Cstme. dwflags = Tme_leave | tme_hover;
Cstme. hwndtrack = M_hwnd ; // SpecifyTrackingWindow
Cstme. dwhovertime = 10; // The status is hover only when the mouse stays on the button for more than 10 ms
:: _ Trackmouseevent (& Cstme ); // Enable wm_mouseleave and wm_mousehover events for Windows
_ Bmousetrack = False ; // IfTracking, StopTracking
}
3. You can track the mouse status again in onmouseleave.
_ Bmousetrack =True;
4. Note: you must write the mappings between the two messages by yourself.
On_message (wm_mousehover, onmousehover)
On_message (wm_mouseleave, onmouseleave)