Click here to Skip to main content
Rate this: bad
good
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 19:33pm
Comments
SAKryukov at 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.
--SA
RKnGl at 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
good
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
        TRACKMOUSEEVENT tme;
        tme.cbSize = sizeof(tme);
        tme.hwndTrack = m_hWnd;
        tme.dwFlags = TME_LEAVE;
        tme.dwHoverTime = 1;
        _TrackMouseEvent(&tme);
  Permalink  
Comments
Moazzam_Munir at 9-Nov-11 2:13am
   
Thanks for the help, it really fixed my problem.
Rate this: bad
good
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... Smile | :)
  Permalink  
v2

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



Advertise | Privacy | Mobile
Web03 | 2.8.150326.1 | Last Updated 7 Nov 2011
Copyright © CodeProject, 1999-2015
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