TApplicationOnHelp (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

The following code changes the Help file depending on the active form, before the help viewer is called. AppHelp is assigned to the OnHelp event handler of the application in the OnCreate event of Form1.

Code

function TForm1.AppHelp(
  Command: Word; Data: Longint; var CallHelp: Boolean) : Boolean;
var helpstring : String;
begin
  helpstring := Screen.ActiveForm.Name + '.hlp';
  MessageDlg(
    'Using ' + helpstring + ' as the help file.',
    mtInformation, [mbOK], 0);
  Application.HelpFile := helpstring;
  CallHelp := True;
end;

procedure TForm1.Button1Click(Sender: TObject);
const DATANOTFOUND = 714;
begin
  Application.HelpContext(DATANOTFOUND);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.OnHelp := AppHelp;
end;

Uses