Treat a message to leave the window (WM

zhaozj2021-02-08  262

Handling the message of the mouse to leave the window (WM_MOUSELEAVE)

WM_MouseLeave is a message issued when the mouse leaves the window, but this message is different from the normal mouse message, to receive the WM_MouseEleave message, you must call TRACKMOUSEEVENT first, and each time the TRASEEVENT window can only receive a WM_MouseLeave, which is also said to get WM_MOUSELEAVE If the message, TRACKMOUSEEVENT must be called when the mouse re-enters the window.

Static Bool BTRACKLEAVE = FALSE;

Void CMYWND :: OnMousemove (uint nflags, cpoint point)

{

IF (! btrackleave)

{

// When the mouse is first moved into the window, ask a WM_MOUSELEAVE message.

TrackMouseEvent TME;

Tme.cbsize = Sizeof (TME);

Tme.hwndtrack = m_hwnd;

Tme.dwflags = TME_LEVE;

_TrackMouseEvent (& TME);

BTRACKLEAVE = True;

/ / Add the code to process the mouse here:

..................................

}

}

Handmade add message mapping and message processing functions

Begin_MESSAGE_MAP (CMYWND, CWND)

// {{AFX_MSG_MAP (CMYWND)

.........................

//}} AFX_MSG_MAP

ON_MESSAGE (WM_MOUSELEAVE, ONMOUSELEAVE)

END_MESSAGE_MAP ()

LPARAM CMYWND :: OnMouseLeave (WPARAM WP, LPARAM LP)

{

BTRACKLEAVE = FALSE;

/ / Add the code that is processed by the mouse here:

........................................

Return 0;

}

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

New Post(0)