Lazarus
July 31, 2010, 03:16:37 am *
  Home   Forum   Help Search Login Register  
* * *
Pages: [1]
  Print  
Author Topic: Pressing F1 to open a CHM helpfile in a Lazarus application  (Read 3058 times)
JD
Full Member
***
Posts: 175


« on: October 05, 2009, 09:51:14 pm »

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.
Logged
andyman
Newbie
*
Posts: 48


« Reply #1 on: October 06, 2009, 02:09:35 am »

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:
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
Logged
JD
Full Member
***
Posts: 175


« Reply #2 on: October 06, 2009, 06:51:13 am »

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.
« Last Edit: October 06, 2009, 07:00:58 am by JD » Logged
JD
Full Member
***
Posts: 175


« Reply #3 on: October 15, 2009, 12:32:09 pm »

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.
Logged
marcov
Sr. Member
****
Posts: 254


- - -
« Reply #4 on: December 04, 2009, 11:01:20 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
Logged
marcov
Sr. Member
****
Posts: 254


- - -
« Reply #5 on: December 08, 2009, 09:42:16 am »

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
Logged
davesimplewear
Full Member
***
Posts: 236



WWW
« Reply #6 on: December 09, 2009, 12:57:24 am »

This is not strictly on topic, but does chmWriter wotk in linux?
Logged

All things considered insanity seems the best option
marcov
Sr. Member
****
Posts: 254


- - -
« Reply #7 on: December 09, 2009, 09:43:05 am »

This 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.
Logged
marcov
Sr. Member
****
Posts: 254


- - -
« Reply #8 on: December 30, 2009, 01:30:20 pm »

Last night I tested CHMwriter to test adding context ids, and I found a bug. Evil

Use 2.5.1 of today or later if you want to _generate_ context sensitive help based on IDs.
Logged
JD
Full Member
***
Posts: 175


« Reply #9 on: January 11, 2010, 08:23:43 am »

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

This is the code I used to implement CHM help for my Lazarus Windows application.

Code:
(*-----------------------------------------------------------------------------
                 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:
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
Logged
marcov
Sr. Member
****
Posts: 254


- - -
« Reply #10 on: January 11, 2010, 03:08:26 pm »

Have a look at the fpc/packages/winunits-base/tests dir, most notably hhex.pp and hhex2.pp

Logged
HarryMudd
Newbie
*
Posts: 1


« Reply #11 on: January 30, 2010, 11:11:41 pm »

Hello, sorry for my bad english Smiley

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/fid34DE68AEB65566AA668889D5CFD863201252CBF2.aspx?s=htmlhlp#L14"

This unit is for Delphi and Kylix, but it is easy to portable to fpc.

Bye
Logged
Pages: [1]
  Print  
 
Jump to:  

Recent

Get Lazarus at SourceForge.net. Fast, secure and Free Open Source software downloads
TinyPortal v1.0 beta 4 © Bloc
Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!