Recent

Author Topic: How to link to chm file from character-based app?  (Read 4317 times)

dculp

  • Full Member
  • ***
  • Posts: 151
How to link to chm file from character-based app?
« on: November 09, 2016, 05:15:43 pm »
I'm updating a character-based app (no panels, components, etc.) from Turbo Pascal 7 so that it will run under Win7+. When the cursor sits at a particular option, I want to show chm help for that option when I press the F1 key. Assuming that I would have the chm file, how do I do this? What function(s) need to be called? What parameters do I need to pass? What "uses" files are needed? Some example code (or reference) would be greatly appreciated.

Lazarus 1.6, FPC 3.0.0

Thanks,
Don C.

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12894
  • FPC developer.
Re: How to link to chm file from character-based app?
« Reply #1 on: November 09, 2016, 05:20:43 pm »
Well, the textmode IDE does that. Basically, you load the CHM, build indexes for it, and build a helpviewer or try to port the textmode IDE's.


Fungus

  • Sr. Member
  • ****
  • Posts: 354
Re: How to link to chm file from character-based app?
« Reply #2 on: November 09, 2016, 05:47:03 pm »
You can use TProcess or ShellExecute or something like that to open the CHM-viewer with a specific page selected using the command:

Code: [Select]
HH.EXE ms-its:path\to\help\file.chm::/path/to/topic.htm

dculp

  • Full Member
  • ***
  • Posts: 151
Re: How to link to chm file from character-based app?
« Reply #3 on: November 09, 2016, 07:38:19 pm »
Well, the textmode IDE does that. Basically, you load the CHM, build indexes for it, and build a helpviewer or try to port the textmode IDE's.

I'm using external editors to create the Pascal files and the chm files. I only use the Lazarus GUI editor for Project control and compiling.
Where is the textmode IDE? Does it come with the Lazarus download?
"you load the CHM" -- load the CHM into the textmode IDE?
"build a helpviewer" -- I don't understand. I would expect to use Windows standard chm viewer.
" or try to port the textmode IDE's" -- can you explain further

Thanks.


Fungus

  • Sr. Member
  • ****
  • Posts: 354
Re: How to link to chm file from character-based app?
« Reply #4 on: November 09, 2016, 07:55:03 pm »
marcov's answer is made in the belief that you wanted to load the CHM-topic into your console / textmode application as text. This would require a lot of coding since no such feature exist (AFAIK). If you want to load the topic using Microsoft Html Help you must use the command provided above and specify the help file and the topic name as arguments. You will need to be able to translate the command in your console application to a topic file (eg. a "copy" command is clicked, this could translate to topic "/commands/copy.htm").

Get more info about hh.exe and how to invoke it from a command line here: http://www.help-info.de/en/Help_Info_HTMLHelp/hh_command.htm
« Last Edit: November 09, 2016, 07:57:51 pm by Fungus »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12894
  • FPC developer.
Re: How to link to chm file from character-based app?
« Reply #5 on: November 09, 2016, 08:48:30 pm »
Where is the textmode IDE? Does it come with the Lazarus download?
"you load the CHM" -- load the CHM into the textmode IDE?
"build a helpviewer" -- I don't understand. I would expect to use Windows standard chm viewer.

If you don't want the result to be character based, and don't mind windows only, you can use the HTMLHELP api calls.

See the demoes in the  packages\winunits-base\tests directory in the FPC sources. I assume they come with Lazarus

dculp

  • Full Member
  • ***
  • Posts: 151
Re: How to link to chm file from character-based app?
« Reply #6 on: November 10, 2016, 02:36:29 pm »
Where is the textmode IDE? Does it come with the Lazarus download?
"you load the CHM" -- load the CHM into the textmode IDE?
"build a helpviewer" -- I don't understand. I would expect to use Windows standard chm viewer.

If you don't want the result to be character based, and don't mind windows only, you can use the HTMLHELP api calls.

See the demoes in the  packages\winunits-base\tests directory in the FPC sources. I assume they come with Lazarus

It looks like Lazarus\fpc\3.0.0\source\packages\winunits-base\tests\hhex.pp (attached) will work. However, when I compile I get a hint  --
   "Conversion between ordinals and pointers is not portable"
This occurs at ptruint(pchar(htmltopic)) of the following line --
   Res:=HtmlHelpA(0,pchar(helpfilename) ,HH_DISPLAY_TOPIC,ptruint(pchar(htmltopic)));   
The compiler gives the explanation --
   "If you typecast a pointer to a longint (or vice-versa), the code will not compile on a machine using 64 bit addressing."

Otherwise, the code compiles OK under Win7 Professional. Since I don't plan to distribute the source code, is this a problem? In any case, however, can the code be rewritten to avoid this?


marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12894
  • FPC developer.
Re: How to link to chm file from character-based app?
« Reply #7 on: November 10, 2016, 05:04:33 pm »
No way, except disabling warnings The windows api is siimply untyped there (that last parameter can be used for differnet types depending on the second param)

 

TinyPortal © 2005-2018