How to use CHM HTML Help file with Delphi XE application?
Asked Answered
A

1

5

Delphi - How to use CHM HTML Help file with Delphi XE application?

http://edn.embarcadero.com/article/27842 article describes how to use CHM file. I did all the steps described there.

Added

const
  HH_DISPLAY_TOPIC        = $0000;
  HH_DISPLAY_TOC          = $0001;
  HH_CLOSE_ALL            = $0012;

function HtmlHelp(hwndCaller: HWND;
  pszFile: PChar; uCommand: UINT;
  dwData: DWORD): HWND; stdcall;
  external 'HHCTRL.OCX' name 'HtmlHelpA';

and public function HH`

function TForm1.HH(Command: Word; Data: Integer;
  var CallHelp: Boolean): Boolean;
begin
  if (Command = 0) and (Data = 0) then
      HtmlHelp(Application.Handle,
        PChar(Application.HelpFile),
        HH_DISPLAY_TOC, 0);

  CallHelp := False;
end;

In FormCreate

  HelpDir:=ExtractFilePath(Application.EXEName);
  Application.HelpFile:=HelpDir+'Sample.chm';
  Application.OnHelp := HH;

On the button1 OnClick event added the following code:

HH(0, 0, dummy);

After clicking on the button1, cursor becomes an hourglass for a while, and that's all.

What I'm doing wrong ?

And how the CHM help file can be used from DelphiXE application?

Abvolt answered 3/2, 2014 at 18:8 Comment(6)
Don't you just add HtmlHelpViewer to your uses clause? And that should be it.Halley
HTMLHelpViewer is in my uses clause,so it's not the reason.Abvolt
If you use that you need nothing elseHalley
Thank You. I've created a help test project. It works there. But it doesn't work in my main project ((, which is a MDI application.Abvolt
Clearly you've got something wrong in your project. Can't tell what from here.Halley
Use HtmlHelpW instead of HtmlHelpA if you are using Unicode (XE already support Unicode).Wooer
H
10

The article you are working from pre-dates built in support for HTML help. These days you do the following:

  • Include HtmlHelpViewer in at least one of your uses clauses.
  • Set Application.HelpFile to the path of your help file.

And that's it. The code in your question should be removed. The built-in help viewer takes care of all those details.

Halley answered 3/2, 2014 at 18:40 Comment(3)
Include HtmlHelpViewer and Set Application.HelpFile and like a miracle everything goes by itself. OP has informed you HTMLHelpViewer is in my uses clause,so it's not the reason. Also as you can clearly see he uses Application.HelpFile:=HelpDir+'Sample.chm'; and now? Your answer has as always immediately 2 upvotes. But can not help OP. This is a pity.Idiopathy
@moskito I don't understand your commentHalley
Just in case someone still use Delphi 5 (same as me) it should be UseHTMLHelp instead of HtmlHelpViewer.Satterwhite

© 2022 - 2024 — McMap. All rights reserved.