How to add support of HTML help files (.chm) on Delphi XE2? We need to use A-links (A-keywords) on HelpContext
property of every control to lookup help pages. Delphi XE2 has native support of HTML help files by unit HTMLHelpViewer
. But how to use it?
I suspect that to use A-links you need to do the following:
Application.OnHelp
handler as described below.Application.HelpFile
during program startup.Application.HelpKeyword
if you wish to invoke the help system with an A-link.HelpKeyword
property for any GUI controls that you wish to respond to context sensitive F1 key presses.The OnHelp
handler looks like this:
function TMainForm.ApplicationHelp(Command: Word;
Data: THelpEventData; var CallHelp: Boolean): Boolean;
var
Link: THH_AKLink;
ALink: string;
begin
CallHelp := False;
Result := True;
//argh, WinHelp commands
case Command of
HELP_COMMAND:
begin
ZeroMemory(@Link, SizeOf(Link));
Link.cbStruct := SizeOf(Link);
ALink := PChar(Data); // we are going to re-purpose the keyword as an A-link
Link.pszKeywords := PChar(AnsiString(ALink)); // seems we have to pass a PAnsiChar ..
Link.fIndexOnFail := True;
HtmlHelp(GetDesktopWindow, Application.HelpFile, HH_ALINK_LOOKUP,
DWORD_PTR(@Link));
end;
end;
end;
The HtmlHelpViewer
unit contains methods named LookupALink
which do the same. But I don't see how they could ever be called.
The above approach is a little bit hacky because it interprets keywords as A-Links. If you want context sensitive help, I can't see what else you can do.