How to Connect HTML Help with your Delphi Application

If you are a Delphi developer, you can integrate an HTML Help (.CHM) system with your application by using the HTMLHelpAPI.pas unit.


In the Delphi environment:

  1. On the "Project" menu, click "Add to Project".
  2. Select the downloaded file "HTMLHelpAPI.pas" and click "Open".


Then you should add HTMLHelpAPI.pas to the Uses clause of the unit(s) in which you need to access HTML Help API. For example, you can add it to the Uses clause of the main form.


Link your .CHM file with your application by setting the Application.HelpFile value. You can do so in the main form creation event.


For example:


procedure TMainForm.FormCreate(Sender: TObject);

begin

  Application.HelpFile:= ExtractFilePath(Application.ExeName) +

    'MyHelpFile.chm';

end;


Now you can perform the operations such as displaying a particular help topic, opening the help system, and so on by using the following calls:


1. Displaying a help topic:

HHHelpContext(MyTopicContextID);


where MyTopicContextID is the number topic identifier of the help topic to display as defined in your help project.


2. Displaying TOC:

HHCommand(HH_DISPLAY_TOC, 0);


You can use this command to implement the Show Help command, when the user calls the help system from a menu or by pressing F1 in your application. In this case, we do not call a help topic, but pass the HH_DISPLAY_TOC constant to the HTMLHelp() function.


3. Displaying the Index:

HHCommand(HH_DISPLAY_INDEX, 0);


You can download the unit HTMLHelpAPI.pas from of our website.

Learn More About HelpSmith