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.
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';
The code below will open your help file at the topic with Context Number equal to 50:
Application.HelpContext(50);
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);
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.
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');
You can also visit the links below for information on using a CHM file in other development tools.
You can download one of the recommendable help authoring tools that combines a rich feature-set, slight learning curve, and affordable price.