我无法在打开和保存对话框中获得 Delphi 上下文相关帮助
我有一个带有 CHM 帮助文件的 Delphi 2006 应用程序。一切正常,除了我无法获得任何连接到 TOpenDialog 和 TSaveDialog 上的“帮助”按钮的帮助。
下面显示了一个简单的程序来演示这一点。单击按钮 2 打开帮助文件并显示正确的页面。单击按钮 1 打开对话框,但单击对话框中的帮助按钮没有任何效果。
unit Unit22;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,
HTMLHelpViewer ;
type
TForm22 = class(TForm)
OpenDialog1: TOpenDialog;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form22: TForm22;
implementation
{$R *.dfm}
procedure TForm22.Button1Click(Sender: TObject);
begin
OpenDialog1.HelpContext := 10410 ;
OpenDialog1.Execute ;
end;
procedure TForm22.Button2Click(Sender: TObject);
begin
Application.HelpContext (10410) ;
end;
procedure TForm22.FormCreate(Sender: TObject);
begin
Application.HelpFile := 'c:\help.chm' ;
end;
end.
I have a Delphi 2006 app with a CHM help file. It all works OK except that I cannot get any help to connect to the "Help" button on the TOpenDialog and TSaveDialog.
A simple program demonstrating this is shown below. Clicking button 2 opens the help file and displays the correct page. Clicking button 1 opens the dialog, but clicking on the help button in the dialog has no effect.
unit Unit22;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,
HTMLHelpViewer ;
type
TForm22 = class(TForm)
OpenDialog1: TOpenDialog;
Button1: TButton;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form22: TForm22;
implementation
{$R *.dfm}
procedure TForm22.Button1Click(Sender: TObject);
begin
OpenDialog1.HelpContext := 10410 ;
OpenDialog1.Execute ;
end;
procedure TForm22.Button2Click(Sender: TObject);
begin
Application.HelpContext (10410) ;
end;
procedure TForm22.FormCreate(Sender: TObject);
begin
Application.HelpFile := 'c:\help.chm' ;
end;
end.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用默认设置,TOpenDialog 的帮助消息处理不起作用(您应该将其提交到 Quality Central)。
具体原因是因为 Windows 将帮助消息发送到对话框的父级,而不是对话框本身,因此除非将表单设置为处理它,否则它只会被忽略。
解决方法是将 Application.ModalPopupMode 设置为 pmAuto 而不是默认值下午没有。您可以在正常启动代码期间或在显示对话框之前执行一次此操作。设置完成后,Delphi 将创建一个中间窗口 (Dialogs.pas::TRedirectorWindow),它可以正确处理消息。
如果由于某种原因您无法更改 ModalPopupMode 那么,正如我所说,您需要处理表单上的消息:
With default settings TOpenDialog's help message handling doesn't work (you should submit it to Quality Central).
The specific reason is because Windows sends the help message to the dialog's parent, rather than the dialog itself, so unless your form is set up to process it it just gets ignored.
The fix is to set Application.ModalPopupMode to pmAuto instead of the default of pmNone. You can do that once during your normal startup code, or just before you show the dialog. When that's set Delphi creates an intermediate window (Dialogs.pas::TRedirectorWindow) which handles the message correctly.
If for some reason you can't change the ModalPopupMode then, as I said, you need to handle the message on your form: