About WM

xiaoxiao2021-03-06  58

These two news is quirky, although you can find their definition, it seems to be quite useful, but it is not received. Just now 9CBS, someone asked this question, I will answer it, just put it here, to save.

----------------------------------------

WM_MouseEleave, WM_MOUSEENTER should be a custom message because Windows usually does not send this message. Only you call TRACKMOUSEEvent will receive this message.

In fact, this message is TRACKMOUSEEVENT instead of Windows. Very strange Microsoft defines the API of this. And the TRACKMOUSEEVENT personal feeling is not easy to use (mainly to feel awkward, not the function is not functional). In fact, the principle of TrackMouseEvent is also very simple. If you do the three sentences, you don't have to pay attention to Microsoft's ancient quirky API, you have to find a message definition.

The principle is as follows: The mouse receives the MouseMove message when the window is in the window. When you receive this message, it is WM_MOUSEENTER. ON_MOUSEMOVE (...) {static bool bfirst = true; if (bfirst) {// PostMessage (wm_mouseenter ...) or call some function. Bfirst = false; setTimer (...);}}

In the Mouse Enter, a timer is started, usually 100ms is sufficient. Whether the mouse is detected in the timer. ON_TIMER (...) {... getCursorpos (PT); getWindowRect (Rect); if (PtinRect, Pt)) {killtimer (...); // kill self. Postmessage (WM_MOUSELEAVE ...); // or call one function.}

转载请注明原文地址:https://www.9cbs.com/read-117785.html

New Post(0)