Forum > General

Creating context sensitive help

(1/1)

Davo:
Following advice already given in this forum I can activate a chm help file from within a running Lazarus application using the following code :

procedure TForm1.Contents1Click(Sender: TObject);
{Menu item Help | Contents displays the table of contents of the help file}
begin
  {call the procedure which launches the help file}
  LaunchCHMHelp('HelpFileName.chm');
end;

procedure TForm1.LaunchCHMHelp(ProgramName: string);
{launches the help file}
var
  AProcess: TProcess;
begin
  try
    AProcess := TProcess.Create(nil);
    AProcess.CommandLine := 'hh.exe' + ' ' +
         ExtractFilePath(Application.ExeName) + ProgramName;
    AProcess.Execute;
    AProcess.Free;
  except
    MessageDlg('Problem encountered with Help file',mtError,[mbOK],0);
  end;
end;

But is there an easy way to extend the code so as to allow context sensitive calls to the help file?

vvzh:
LCL controls have HelpType, HelpContext and HelpKeyword properties and Application has an event (OnHelp IIRC). I have no idea about whether these are fully working or not, but it seems logical to use them as a starting point.

typo:
This should work:


--- Code: ---function TForm1.FormHelp(Command:Word;Data:PtrInt;var CallHelp:Boolean):Boolean;
begin
  command := HH_DISPLAY_INDEX;
  HtmlHelp(GetDesktopWindow(), pchar(helpfile), command, data);
end;
--- End code ---
 

Unit HtmlHelp is here: http://www.koders.com/delphi/fid34DE68AEB65566AA668889D5CFD863201252CBF2.aspx?s=htmlhlp#L14

Zoran:
I haven't tried it myself, but take a look at this:
http://wiki.lazarus.freepascal.org/Add_Help_to_Your_Application

Navigation

[0] Message Index

Go to full version