Making Help Authoring a Pleasure to Do
Free DownloadStart your free trial now

Help Authoring Articles

Technical Articles

How to Connect HTML Help with your Delphi Application

If you are a Delphi developer, you can easily integrate an HTML Help (CHM) system with your application since modern Delphi versions include built-in support for this help format. Below you will find a description of how to work with HTML Help from your Delphi programs. Also, we have a sample Delphi project which demonstrates everything in action.

Linking HTML Help (CHM) Files

You should add the "HTMLHelpViewer" unit to the "Uses" clause in the main form of your application. Then set the full path to your CHM file to Application.HelpFile property. To do so, you can add the following line to the main form's "On Create" event handler:

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

where "HelpFile.chm" is the actual name of your HTML Help file, located in the same directory as your application's executable file.

Using HTML Help from Code

When you need to display your help file or a specific help topic, or perform others actions, you can use the following calls:

Displaying a help topic

Application.HelpContext(IDH_TOPIC);

where IDH_TOPIC is the ContextId value of the topic to display.

Displaying the Table of Contents tab

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

Displaying the Index tab

HtmlHelp(0, Application.HelpFile, HH_DISPLAY_INDEX, DWORD(PWideChar('Test')));

Displaying the Search tab

var
  Query: THH_Fts_QueryW;
begin
  with Query do
  begin
    cbStruct := SizeOf(THH_Fts_QueryW);
    fUniCodeStrings := True;
    pszSearchQuery := '';
    iProximity := 0;
    fStemmedSearch := True;
    fTitleOnly := False;
    fExecute := True;
    pszWindow := nil;
  end;
  HtmlHelp(0, Application.HelpFile, HH_DISPLAY_SEARCH, DWORD(@Query));
end;

Performing Keyword Lookup

Application.HelpKeyword('Test');

Providing Help for Controls

You can link specific help topics with any controls located on the form. In this case a control will automatically display the corresponding help topic when the user focuses it and presses F1. Also, you can add the standard [?] button to the caption area of the form: using the Object Inspector, set the form's BorderStyle property as bsDialog and biHelp member of the BorderIcons property to True. Then set the controls' HelpContext properties that should correspond to the topic ContextId values as defined in your help project.

Sample Delphi Project

You can download a Delphi project that implements the above examples. Click here to start downloading.

Download HelpSmith

You can download HelpSmith and start creating help files and documentation in multiple formats. For new users, HelpSmith includes sample help projects that will help you get started with the product quickly.

Detail Value
Product HelpSmith 10.1 (Build 24.1206)
Filename HelpSmithSetup.exe
File size 65 MB
Platform Windows 11/10/8/7