Embarcadero Delphi

How to Link an HTML Help .CHM File with a Delphi Application

The latest versions of the RAD Studio provide support for HTML Help files, which simplifies the task of linking a CHM help file with a Delphi application and providing context-sensitive Help.

Below you will find code examples of the basic actions such as calling a help topic, displaying the Table of Contents or Index tab from the Delphi code.

Define the Full Path to Your CHM Help File

First you need to define the location of your CHM help file by setting the value of the Application.HelpFile property.

Typically, the CHM file is located in the same directory as the application's executable (.EXE) file, so the code below relies on the ExtractFilePath() function.

Application.HelpFile := ExtractFilePath(Application.ExeName) + 'YourCHMFile.chm';

Show a Specific Help Topic by Its Context Number

The code below will open your help file at the topic with Context Number equal to 50:

Application.HelpContext(50);

Show the Table of Contents

If you need to simply display your help file at the default topic, so the user will see the Table of Contents tab open, you can use the call below:

HtmlHelp(0, Application.HelpFile, HH_DISPLAY_TOC, 0);

Show the Index tab

Similarly, you can display your help file and open the Index tab by using this code:

HtmlHelp(0, Application.HelpFile, HH_DISPLAY_INDEX, DWORD(PWideChar('Some keyword here')));

Please note that in this case you can also pass a keyword to find associated topics in the Index tab.

Search for a Keyword

Finally, if you need to search for help topics associated with a keyword directly from your Delphi application, you can use the following line of code:

Application.HelpKeyword('Some keyword here');

Related Links

You can also visit the links below for information on using a CHM file in other development tools.

Download a Help Authoring Tool

You can download one of the recommendable help authoring tools that combines a rich feature-set, slight learning curve, and affordable price.

HelpSmith Download

HelpSmith main window

Product Details:

Detail Value
Product HelpSmith 7.3
Filename HelpSmithSetup.exe
File size 40 MB
Platform Windows 10/8/7/Vista/XP
System requirements 1 GHz processor, 512MB RAM, 150MB free disk space