模拟主动控制上的 F1 按键以加载帮助系统 - Delphi

发布于 2025-01-03 08:45:12 字数 334 浏览 3 评论 0原文

我们正在向应用程序的工具栏添加一个帮助按钮。

当用户单击此按钮时,我们需要加载他们所在控件的帮助系统

例如,如果它们位于联系人表单的地址框上,我需要使用其上下文 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

韵柒 2025-01-10 08:45:12

我认为您需要一个工具按钮 OnClick 处理程序,它可以像这样简单:

procedure TMyForm.ToolButton1Click(Sender: TObject);
begin
  if Assigned(ActiveControl) then begin
    Application.HelpContext(ActiveControl.HelpContext);
  end;
end;

使此功能有效的原因是工具栏上的控件永远不会成为活动控件。

I think you need a tool button OnClick handler that can be as simple as this:

procedure TMyForm.ToolButton1Click(Sender: TObject);
begin
  if Assigned(ActiveControl) then begin
    Application.HelpContext(ActiveControl.HelpContext);
  end;
end;

What makes this work is the fact that the controls on a toolbar do not ever become the active control.

迷途知返 2025-01-10 08:45:12

你的工具栏有问题。系统工具栏通常不会获得焦点——它从来都不是活动控件。如果您使用真正的 TToolBarTToolButton,则不会出现此问题。即使是 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 and TToolButton, you won't have this problem. Even TSpeedButton 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文