Mouse Move Capture (Mouse leave & Mouse Enter)
Hi i have three controls (CButtton) in my app开发者_如何学Golication,whenever mouse move over a control,i want to capture when mouse enters on which control in a window and when it leaves and i have to change the caption of a button control.
Thanks in Advance
There is no windows message/event that indicates 'mouse enter' or 'mouse leave'. However this can be achieved by handling the 'MouseMove' message for your control and capturing the mouse input to check if the point is inside the control area. Release the capture if the point is out of the control area.
for sample code check here.
@Hemant:
You are wrong. There are messages for mouse leave and mouse hover, defined in WinUser.h
#if((_WIN32_WINNT >= 0x0400) || (WINVER >= 0x0500))
#define WM_MOUSEHOVER 0x02A1
#define WM_MOUSELEAVE 0x02A3
#endif
#if(WINVER >= 0x0500)
#define WM_NCMOUSEHOVER 0x02A0
#define WM_NCMOUSELEAVE 0x02A2
#endif /* WINVER >= 0x0500 */
Documentation:
WM_MOUSEHOVER message
WM_MOUSELEAVE message
And you can handle it with a message-mapping like:
ON_MESSAGE(WM_MOUSELEAVE, OnMouseLeave)
精彩评论