模拟主动控制上的 F1 按键以加载帮助系统 - Delphi
我们正在向应用程序的工具栏添加一个帮助按钮。
当用户单击此按钮时,我们需要加载他们所在控件的帮助系统
例如,如果它们位于联系人表单的地址框上,我需要使用其上下文 id 加载帮助系统
我正在考虑尝试模仿 F1 按键,然后它会处理事物的上下文 id 元素并加载帮助文件
但是,我无法让它工作,因为它尝试根据活动控件而不是基于活动控件加载帮助我在,即联系地址
有有办法做到这一点吗?本质上,我需要从先前活动的控件发送 F1 按键(假设当前活动的控件是我的工具栏按钮)
我们正在使用 Delphi 2010
Cheers
Paul
We are adding a help button to the toolbar of our application.
When the user clicks on this button, we need to load the help system for the control that they were on
For example, if they are on the address box of the contacts form, I need to load the help system for this using its context id
I was thinking about trying to mimic an F1 keypress which would then take care of the context id element of things and load the help file
However, I cant get this to work because it tries to load the help based on the active control not the one I was on, i.e. the contact address
Is there a way to do this? Essentially I need to send an F1 keypress from previously active control (assuming that the currently active control is my toolbar button)
We are using Delphi 2010
Cheers
Paul
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您需要一个工具按钮
OnClick
处理程序,它可以像这样简单:使此功能有效的原因是工具栏上的控件永远不会成为活动控件。
I think you need a tool button
OnClick
handler that can be as simple as this:What makes this work is the fact that the controls on a toolbar do not ever become the active control.
你的工具栏有问题。系统工具栏通常不会获得焦点——它从来都不是活动控件。如果您使用真正的
TToolBar
和TToolButton
,则不会出现此问题。即使是TSpeedButton
也不会有这个问题。使用适合工作的正确控件。另外,不要尝试“模拟”键盘事件。只需直接调用
Application.HelpContext
即可。There's something wrong with your toolbar. The system toolbar doesn't ordinarily get the focus — it's never the active control. If you're using a real
TToolBar
andTToolButton
, you won't have this problem. EvenTSpeedButton
won't have this problem. Use the right control for the job.Also, don't try to "simulate" a keyboard event. Just call
Application.HelpContext
directly.