由于鼠标悬停事件而显示或隐藏(自动隐藏)工具栏。 [英] Show or Hide (Autohide) a toolbar due to a mouseover event.

查看:236
本文介绍了由于鼠标悬停事件而显示或隐藏(自动隐藏)工具栏。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个带有多个工具栏的MFC C ++应用程序。我想允许工具栏自动隐藏 - 只有当鼠标移动到特定区域(屏幕上的另一个工具栏按钮)时才会显示。



我知道我可以显示或者通过调用ShowWindow(SW_HIDE)来隐藏工具栏 - 我可以通过单击按钮来触发它,但是有人可以建议在将鼠标悬停在按钮上时执行此操作吗?



单击按钮将激活工具栏的自动隐藏 - 因此将鼠标悬停在工具栏上应显示(现在隐藏)工具栏。



有一个跟踪鼠标事件 - 但我不知道如何使用它!

建议?



更新:我发现:< a href =http://www.codeproject.com/Articles/3414/MouseLeave-and-MouseEnter-functions> MouseLeave和MouseEnter函数 [ ^ ]



但我可以不能让它发挥作用。

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.

推荐答案

有趣的想法,但这违反常识可用性指南(IMO)。



你不想隐藏并使其难以使用并在你的应用程序中找到东西。



想象一下,用户必须知道他需要点击或悬停在某个地方才能访问某些功能;用户不是专家用户,会不规律地移动鼠标而会错过热点,必须再试一次;



无论如何,



您必须从CMFCToolbar(可能是CMFCTooolbarButton)派生自己的类才能处理MouseLeave / MouseEnter;从那里,你可以在工具栏(主机)的所有者中设置一个状态来显示工具栏。



或者只需要一个工具栏按钮作为复选框,当按钮向下显示工具栏,当它出现时,隐藏工具栏(可能更容易)
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)


这篇关于由于鼠标悬停事件而显示或隐藏(自动隐藏)工具栏。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆