Click here to Skip to main content
15,038,345 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
Hi I have a MFC C++ app with multiple toolbars. I want to allow a toolbar to autohide - and only be shown when the mouse travels over a specifc area (another toolbar button on screen).

I know I can show or hide the toolbar by calling ShowWindow(SW_HIDE) - and I can trigger this from clicking a button, but can anyone suggest a way to do this on hovering over the button?

Clicking the button will activate the autohide for the toolbar - so hovering over it should show (the now hidden) the toolbar.

There is a track mouse event - but I have no idea how to use it!
Suggestions?

Update: I found this: MouseLeave and MouseEnter functions[^]

But I can't get it to work.
Posted
Updated 3-Oct-13 13:31pm
v2

1 solution

Interesting idea, but this goes against common sense Usability guidelines (IMO).

You do not want to hide and make it difficult to use and to find "stuff" in your application.

Imagine, user will have to know that he needs to click or hover somewhere to have access to some features; user is not an expert user, and will move the mouse erratically and will miss the hotspot and will have to try again;

Anyway,

You will have to derive your own class from the CMFCToolbar (and maybe CMFCTooolbarButton) to be able to handle the MouseLeave/MouseEnter ; from there, you can set a state in the owner of the toolbars ( mainframe) to show the toolbars.

Or simply have a toolbar button act as a checkbox and when the button is down show the toolbars and when it is up, hide the toolbars (might be easier)
   
Comments
Member 10314209 4-Oct-13 12:51pm
   
Hi,
Thanks for the answer - I know it technically goes against user guidelines - but its for an app with a lot of toolbars - some of which won't be used by all users. In applications suck as PaintShopPro there are also Pallets which autohide. I'm working with old code so i can't implement pin-docking - which I think would be standard otherwise. I currently have a show/hide toolbar button, but that appears somewhat clunky - hence to have it auto-hide.

I think it slightly odd that there is no 'mouse-hover' event handler built in - but then, clearly there isn't!

I'm fairly new to C++, any further suggestion on how to derive a class from CMFCToolbar which would accommodate this?

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