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.
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.
Jason Sprenger requested more info in order to validate the issue and commented: Not any code involving “with” statements produces an unsafe typecast warning.
For instance,
What sort of source involving “with” statements is generating these warnings for you?
With this information our development team can consider addressing your particular circumstance.