2004. szeptember 22., szerda

Call another help file from your application


Problem/Question/Abstract:

How do you display a help file that does not belong to your application (i.e. is not specified as Application.HelpFile)?

Answer:

You can call the Winhelp command directly. The Delphi function Application.HelpCommand is simply a wrapper around this call:

procedure TForm1.LaunchHelp(HelpFile: string);
begin
  { The two parameters HELP_FINDER and 0 are the same paramters
    you use in Application.HelpCommand(Command, Data).
    You can use any of the valid parameters here. }

  WinHelp(Form1.handle, PChar(HelpFile), HELP_FINDER, 0);
end;

Important!
The help file you call this way does NOT automatically close when the current form or the application is closed! To ensure that the help file is closed when the user closes the form, add a close command to the OnClose event of the form:

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  WinHelp(Form1.handle, PChar(HelpFile), HELP_QUIT, 0);
end;

Nincsenek megjegyzések:

Megjegyzés küldése