Pressing F1 to open a CHM helpfile in a Lazarus application lazarus / 8-Other ---------------------------------------------------------------------- JD · 2009-10-05 20:51 Hi there everybody. I have a chm help file that I made for an application that I wrote using Lazarus on Windows. How do I configure my application such that users can call and open the help file by pressing F1? In addition, how do I make the calls context sensitive? I'm asking these questions because the Delphi methods for doing this don't seem to work in Lazarus on Windows (I assume because the methods are not cross platform). Thanks. ---------------------------------------------------------------------- Drewski · 2009-10-06 01:09 Hi this link should help ( no pun intended ) http://notcolin.wordpress.com/2009/08/10/the-microsoft-html-help-api- commands/ Also I'm not sure if you wrote the code to make the chm yourself using TCHMWriter but if you did you can use Code: [Select]procedure TChmWriter.AddContext(AContext: DWord; ATopic: String); where AContext is the context number you will give the api to lookup ATopic where ATopic us the url in the chm. ('/html/myspecialpage.html') That's helpful if you assign the context ids in the TControl.HelpContext also the above link gives an example to load a specific url in the chm without adding context numbers in the chm HTH, Andrew ---------------------------------------------------------------------- JD · 2009-10-06 05:51 Thanks for the tips andyman. I didn't use TChmWriter at all, I used another application to create the help file & it is a detailed help file with graphics, links etc. I took a look at the chmhelppkg component bundled with Lazarus & my first impressions of it are that it is more of a viewer to enable the viewing of CHM files on non-Windows platforms. It renders help files poorly on Windows (garbled text, improper display of graphics, search doesn't work & non-English text is mangled on the table of contents). It would be great on Linux though. It's not what I want because it is a bit like re-inventing the wheel to use such a chm viewer on windows. I just want to be able to open the help file by pressing F1! Unfortunately the Delphi code I have that does it noes not work in Lazarus. I don't know if TProcess/TProcessUTF8 would work because I've always believed it is used to run executables. I'll take a closer look at the website you suggested. I hope I find something that will solve this problem there. ---------------------------------------------------------------------- JD · 2009-10-15 11:32 I've solved the problem. It works perfectly now. I've not fully tested the context-sensitive features of the help commands but I'm fairly satisfied with the way it is working now. Thanks for the tip. ---------------------------------------------------------------------- marcov · 2009-12-04 10:01 Quote from: JD on October 06, 2009, 07:51:13 am I took a look at the chmhelppkg component bundled with Lazarus & my first impressions of it are that it is more of a viewer to enable the viewing of CHM files on non-Windows platforms. It renders help files poorly on Windows (garbled text, improper display of graphics, search doesn't work & non-English text is mangled on the table of contents). It would be great on Linux though. It's not what I want because it is a bit like re-inventing the wheel to use such a chm viewer on windows. In the next FPC version, there will be a htmlhelp unit in package winunits-base, which has the (4 or 5) basic prototypes to search windows-internal help. I however had the feeling the windows api is mostly used for ordinary applications, and doesn't match up to the specific demands of an IDE.  So while generated apps might use windows help directly in the "far" future, I doubt the IDE will ---------------------------------------------------------------------- marcov · 2009-12-08 08:42 If somebody has an example of a normal application using CHM for help, I'd like to have it. Either via lazarus' helpsystem or directly via the api ---------------------------------------------------------------------- davesimplewear · 2009-12-08 23:57 This is not strictly on topic, but does chmWriter wotk in linux? ---------------------------------------------------------------------- marcov · 2009-12-09 08:43 Quote from: davesimplewear on December 09, 2009, 12:57:24 amThis is not strictly on topic, but does chmWriter wotk in linux? Yes, and on FreeBSD. In fact the FPC/Lazarus chms are generated on Linux or FreeBSD in general (see below URL)  OS X/x86 works fine too. http://www.stack.nl/~marcov/doc-chm.zip There have some brief tests to check endian safeness from time to time, so the package should generally be endiansafe, but there could be occasional endianess bugs. ---------------------------------------------------------------------- marcov · 2009-12-30 12:30 Last night I tested CHMwriter to test adding context ids, and I found a bug. Use 2.5.1 of today or later if you want to _generate_ context sensitive help based on IDs. ---------------------------------------------------------------------- JD · 2010-01-11 07:23 Quote from: marcov on December 08, 2009, 09:42:16 amIf somebody has an example of a normal application using CHM for help, I'd like to have it. Either via lazarus' helpsystem or directly via the api This is the code I used to implement CHM help for my Lazarus Windows application. Code: [Select](*------------------------------------------------------ -----------------------                  Launch an external application Adapted from Source: http://wiki.lazarus.freepascal.org/Executing_External_Programs ---------------------------------------------------------------------- --------*) procedure LaunchCHMHelp(ProgramName: string); var   AProcess: TProcess; begin   try     // Create the TProcess object, and     // assign it to the var AProcess.     AProcess := TProcess.Create(nil);     // Use AProcess to execute the Microsoft HTML Help file in the windows directory     // The "10" in "-mapid 10 ms-its:" signifies the table of contents     AProcess.CommandLine := 'hh.exe' + ' ' + '-mapid 10 ms-its:' +          ExtractFilePath(Application.ExeName) + ProgramName;;     // Now that AProcess knows what the commandline is     // we will run it.     AProcess.Execute;     // Free AProcess     AProcess.Free;   except     MessageDlg('Le fichier << ' + ProgramName + ' >> est introuvable', mtError, [mbOK], 0);   end; end; The code below opens the CHM helpfile when F1 is pressed or when a toolbar button is clicked Code: [Select]procedure TfrmMainform.HelpContents1Execute(Sender: TObject); begin   // Display the table of contents of the help file   LaunchCHMHelp('Helpfile.chm'); end; "HelpContents1" is a TToolButton on the menu toolbar with its Shortcut property set to F1 i.e HelpContents1.ShortCut := 'F1'. So pressing F1 or clicking on the TToolButton with open the CHM help file. You can use another shortcut if you wish. There are many other options that you can set at designtime under the Action property of the TToolButton. Cheers, JD ---------------------------------------------------------------------- marcov · 2010-01-11 14:08 Have a look at the fpc/packages/winunits-base/tests dir, most notably hhex.pp and hhex2.pp ---------------------------------------------------------------------- HarryMudd · 2010-01-30 22:11 Hello, sorry for my bad english You can use htmlhlp.pas and overrides the THelpManager from helpintfs. Then the Application can call *.chm help by keyword like "hh.exe myhelp.chm::/mysite.html#mycontent". You dont needs TProcess. The htmlhlp.pas can downloaded by "http://www.koders.com/delphi/fid34D E68AEB65566AA668889D5CFD863201252CBF2.aspx?s=htmlhlp#L14" This unit is for Delphi and Kylix, but it is easy to portable to fpc. Bye