I hardly use help files, but some older systems do, and when porting really old Delphi code, often odd implementations of accessing them through HHCTRL.OCX are used.
Since I tend to forget the correct way using the HtmlHelpViewer unit, here are some links:
- [WayBack] How to Connect HTML Help with your Delphi Application
- [WayBack] How to Integrate a CHM File with Your Application
- [WayBack] How to use CHM HTML Help file with Delphi XE application? – Stack Overflow
Very old code involving the OCX file:
- [WayBack] www.stbbs.net/~junichi/adelieworks/hhwd/files/awhhelp.pas
- [WayBack] MiniHtmlHlp.pas in delphi-nonvcl-librarys | source code search engine
Quote from the first link [WayBack] How to Connect HTML Help with your Delphi Application:
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_TOPICis 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.
–jeroen






