How to load Help File (.chm file) in your Delphi Project using HTMLHelpViewer?

How to load Help File (.chm file) in your Delphi Project using HTMLHelpViewer?

Having the help option in your Delphi project is very common in which you want to load the chm file. If you want to create such a functionality in your project, here is the solution. It is very simple in Delphi. Following are the steps which you require to implement help functionality in your Delphi Project.

1. Create a valid chm file and place it in a directory where your exe is placed.

2. Include a unit "HTMLHelpViewer" under your uses section. HTMLHelpViewer is needed to register a viewer for HTML help.

3. On the click of help menu button, put the following code:

procedure TMyForm.ExecuteHelp(Sender: TObject);
begin
  If Application.HelpFile <> '' then
    Application.HelpCommand(HELP_CONTEXT,100) 
  else
    Messagedlg('Cannot load help file');
end;

Application.HelpFile fetches the exact address of your chm file. Application.HelpCommand(HELP_CONTEXT,100) loads your chm file in your Delphi project.

I think this simple tutorial will be useful to you for creating help file in your Delphi project.