RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TApplication.OnHelp Event

Occurs when the application receives a request for help.

Pascal
property OnHelp: THelpEvent;
C++
__property THelpEvent OnHelp;

Write an OnHelp event handler to perform special processing when the user requests help. The HelpContext and the HelpJump methods automatically trigger the OnHelp event. 

Set CallHelp to true if the application should still invoke the help system after the event. Set CallHelp to false to prevent the default response by the help system. All application help methods go through OnHelp. The application calls the help system only if OnHelp's CallHelp parameter returns true or if no OnHelp event handler is assigned. 

The event handler returns true if it succeeds, false if it fails.

Note: You can also respond to this event using the TApplicationEvents component, which allows you to assign an event handler using the IDE.
 

C++ Examples: 

 

/*
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 Application in the
OnCreate event of Form1.
*/
bool __fastcall TForm1::AppHelp(Word Command, int Data, bool &CallHelp)
{
  Application->HelpFile = Screen->ActiveForm->Name + ".hlp";
  CallHelp = true;
  return true;
}

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  Application->OnHelp = AppHelp;
}

void __fastcall TForm1::Button1Click(TObject *Sender)
{
  const DATANOTFOUND = 714;
  Application->HelpContext(DATANOTFOUND);
}

 

Delphi Examples: 

{
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 Application in the
OnCreate event of Form1.
}
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;

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!