I'm building my help system into my program, and I'm working on my context sensitive help which should bring up the appropriate help page for the active control when F1 is pushed.
On each control, I can set HelpType to htContext and HelpContext to the HelpID, or I can set HelpType to htKeyword and HelpContext to the HelpID Alias.
But in my help system (Dr. Explain), I have set up symbolic names (i.e. some text that is used as a bookmark in my help system). This is different than the HelpID and its alias, and is accessible from the Help system with the call: Application.HelpJump(SymbolicName).
I would like to use the HelpContext field for my symbolic names which is much simpler and easier to maintain than creating a duplicate set of HelpID Aliases. And I won't have to worry about creating the Help map file or have to deal with it.
It is the HelpKeyword routine, in the Forms unit, that processes the F1 when when HelpType is htKeyword:
function TApplication.HelpKeyword(const Keyword: string): Boolean;
var
CallHelp: Boolean;
begin
{$IF DEFINED(CLR)}
Result := DoOnHelp(HELP_COMMAND, TObject(Keyword), CallHelp);
{$ELSE}
Result := DoOnHelp(HELP_COMMAND, Integer(PChar(Keyword)), CallHelp);
{$IFEND}
if CallHelp then
begin
if ValidateHelpSystem then
begin
{ We have to asume ShowHelp worked }
Result := True;
HelpSystem.ShowHelp(Keyword, GetCurrentHelpFile);
end
else
Result := False;
end;
end;
To get this to work to process my symbolic names, all I really have to do is replace the routine with:
function TApplication.HelpKeyword(const Keyword: string): Boolean;
begin
Application.HelpJump(Keyword);
Result := true;
end;
What I can't seem to do is figure out how to write the proper code to customize the functionality of this routine in a clean way, without having to hack the Forms unit itself. How can I do this?
Or alternatively, is there another way to easily get the context sensitive help to access my help page based on the symbolic name?
For reference, I'm using Delphi 2009 (but will be upgrading to XE2 in the next month or so).
p.s. The word in the title is "He-lp" because stackoverflow won't let me put the word "Help" in the title.
Try this in your
OnHelp
event handler (of your form, or of the global Application, depending on what you're using):