Recent

Author Topic: Creating context sensitive help  (Read 6660 times)

Davo

  • Full Member
  • ***
  • Posts: 134
Creating context sensitive help
« on: May 28, 2010, 07:20:45 pm »
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

  • Jr. Member
  • **
  • Posts: 58
Re: Creating context sensitive help
« Reply #1 on: May 30, 2010, 09:21:15 am »
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

  • Hero Member
  • *****
  • Posts: 3051
Re: Creating context sensitive help
« Reply #2 on: May 30, 2010, 09:28:58 am »
This should work:

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

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

Zoran

  • Hero Member
  • *****
  • Posts: 1882
    • http://wiki.lazarus.freepascal.org/User:Zoran
Re: Creating context sensitive help
« Reply #3 on: May 30, 2010, 11:15:45 am »
I haven't tried it myself, but take a look at this:
http://wiki.lazarus.freepascal.org/Add_Help_to_Your_Application

 

TinyPortal © 2005-2018