Click here to Skip to main content
12,547,806 members (36,365 online)
Rate this:
Please Sign up or sign in to vote.
See more: C++ MFC
I am developing an outlook bar control in visual C++ using MFC classes. Currently when the mouse hovers a button, then a 3D look is generated to show that mouse is currently on that button and when i move the mouse from this button to the next, the previous button gets to normal state and the new button over which the mouse has now moved shows a 3D look. Until now things are going fine.

The problem is that when i move the mouse to the first button in the outlook bar control, it gives 3D look which is good, but when i move the mouse further up so that it leaves the boundary of the control, then the button remains in that 3D position which is wrong, instead it should restore its normal position.

I am handling this functionality in the when_mouse_move event handler. Actually when mouse moves from first button to the tool bar of the main window, then it neither receives the when_mouse_move message nor it receives the when_mouse_leave message to indicate me that mouse has passed beyond the boundary of the control. Kindly help me to fix this issue.
Posted 6-Nov-11 18:33pm
SAKryukov 7-Nov-11 1:03am
Can you make a simple code sample to manifest the problem? Hard to say anything before looking at how you do it.
RKnGl 7-Nov-11 4:49am
Once, I had an issue with the form element "below" comboBox that was "stealing" desired behavior from it... Maybe You should check the behavior of , if any, panels/ toolbars that hold Your buttons ?

P.S. This behavior occurred only in specific situations when I had some sort of "skinning" and theme forms with inherited preferences .. Can't hurt to check most banal thing 1st ...
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

Windows does not automatically send a WM_MOUSELEAVE message. When the mouse enters the control, you need to call _TrackMouseEvent to get it to notify you when this occurs:

// track the mouse so we know when it leaves our window
tme.cbSize = sizeof(tme);
tme.hwndTrack = m_hWnd;
tme.dwFlags = TME_LEAVE;
tme.dwHoverTime = 1;
Moazzam_Munir 9-Nov-11 2:13am
Thanks for the help, it really fixed my problem.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

Some MS Windows controls (for example the list control header)
are handling the "OnMouseLeave" event by their own
OnTimer(..) callbacks (what window or its part is under mouse?).

Try to do it too... :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.161021.1 | Last Updated 7 Nov 2011
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100