覆盖标题栏按钮的工具提示文本(关闭、最大化、最小化、帮助)
我一直在尝试更改表单主标题栏上的按钮显示的工具提示文本,但没有成功。
简而言之,我们利用 Windows 窗体的“帮助”按钮来实现其他目的。这工作正常。问题是,当将鼠标悬停在该按钮上时,会出现“帮助”工具提示,这对应用程序没有任何意义。
理想情况下,有某种方法可以更改我的应用程序的工具提示文本;然而,此时我只要找到一种完全禁用工具提示的方法就很满意了。
我知道您可以通过修改 regedit 中的“UserPreferencesMask”键来禁用整个操作系统的工具提示,但我真的希望有一种方法让它只影响我的应用程序。
同样,理想情况下应该有某种方法可以使用托管代码来执行此操作,但我不反对链接到 Windows API 等。
感谢您提供解决此问题的任何建议!
I have been trying without luck to change the text of the tooltip that appears for the buttons on the main title bar of a form.
In a nutshell, we have harnessed the 'Help' button for Windows Forms to have some other purpose. This is working fine. The issue is that when hovering the mouse over that button, a 'Help' tooltip appears, which doesn't make any sense for the application.
Ideally, there would be some way to change the text of that tooltip for my application; however, at this point I would be satisfied just finding a way to disable the tooltips altogether.
I know that you can disable the tooltips for the entire OS by modifying the 'UserPreferencesMask' key in regedit, but I would really like a way to have this only affect my application.
Again, ideally there would be some way to do this with managed code, but I would not be opposed to linking into the Windows API or the like.
Thanks for any suggestions for resolving this issue!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
作为解决方法,您可以不使用帮助按钮,而是:添加自定义按钮。
虽然这个示例不太完美,但它向您展示了这个想法。
As a workaround, you may not use the help button, instead: add your custom button.
Although this sample not so perfect, but it shows you the idea.
这是一个非常有趣的问题。我的第一个想法是使用 GetSysMenu 更改系统菜单。我尝试删除并重命名“关闭”项目,但“关闭”按钮的工具提示没有改变。然后我尝试捕获工具提示窗口的HWND,但没有成功。如果我让表单(我在 Delphi 中工作)显示一个名为“Test”的工具提示,我可以通过 FindWindow(nil, 'Test') 获取它的 HWND,然后我可以向它发送 WM_CLOSE 消息。
在下面的示例代码中,我使用计时器不断搜索工具提示。这对性能不利,因此人们希望确切地知道工具提示何时出现。在这种情况下,当工具提示与客户端控件关联时,可以简单地使用 OnHint 事件。
然而,当工具提示与标题栏按钮关联时,存在两个问题。
This is an extremely interesting question. My first idea was to alter the system menu, using GetSysMenu. I tried both to remove and rename the "Close" item, but the tooltip of the Close button did not change. Then I tried to capture the HWND of the tooltip window, but I did not succeed. If I let the form (I work in Delphi) display a tooltip named "Test", I can get its HWND by FindWindow(nil, 'Test'), and then I can SendMessage WM_CLOSE to it.
In the following sample code, I use a timer to constantly search for the tooltip. This is bad for performance, so one would want to find out exactly when the tooltip appears. In this case, when the tooltip is associated with a client control, one can simply use the OnHint event.
However, there are two problems when the tooltip is associated with the title bar buttons.