Click here to Skip to main content
15,878,231 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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.
Sergey Alexandrovich Kryukov 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 ...

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;
Share this answer
Moazzam_Munir 9-Nov-11 2:13am    
Thanks for the help, it really fixed my problem.
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... :)
Share this answer

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

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900