1

In Embarcadero Delphi XE7, I use a component which has a help-button. In the component (which shows a message dialog), I specify a help context number. If the user clicks on the button, the help should show, but I get an error instead:

Project ... raised exception class $C00000FD with message 'stack overflow at 0x006f089e'.

The command executed when the user clicks on the button is:

Application.HelpContext(HelpContextNumber);

On Launch HTML Help as Separate Process, I read that I should attach an OnHelp event handler to the Application object.

I saved the Help unit but how do I attach it?

Application.OnHelp := ....?
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • Please add some relevant tags to your question by using the `edit`button. I assume it's Delphi? – help-info.de Aug 06 '20 at 08:47
  • Please have a look at https://stackoverflow.com/questions/21534449/how-to-use-chm-html-help-file-with-delphi-xe-application – help-info.de Aug 06 '20 at 08:52
  • I know how to attach a htmlhelp file to my application. On other points in my app the help show coerrect. Only not from this component.That is why I want to try the solution in https://stackoverflow.com/questions/30336018/launch-html-help-as-separate-process but I don't know how to attach the help file to the application. – Andre Hesdahl Aug 06 '20 at 11:30
  • I don't quite understand what your question is. Do you want to know how to create a function that you can assign to `Application.OnHelp`, or do you want to know what that procedure should do? – Andreas Rejbrand Aug 06 '20 at 15:55

1 Answers1

0

The TApplication.OnHelp event is declared as a THelpEvent:

THelpEvent = function(Command: Word; Data: THelpEventData; var CallHelp: Boolean): Boolean of object;  

So, you would need to declare a method in your Form like this:

type
  TMyForm = class(TForm)
    ...
  private
    function MyOnHelpHandler(Command: Word; Data: THelpEventData; var CallHelp: Boolean): Boolean;
    ...
  end;

And then you can assign that handler to the TApplication.OnHelp event at runtime, eg:

procedure TMyForm.FormCreate(Sender: TObject);
begin
  Application.OnHelp := MyOnHelpHandler;
end;

procedure TMyForm.FormDestroy(Sender: TObject);
begin
  Application.OnHelp := nil;
end;

function TMyForm.MyOnHelpHandler(Command: Word; Data: THelpEventData; var CallHelp: Boolean): Boolean;
begin
  Result := ...;
end;

Alternatively, you can drop a TApplicationEvents component onto your Form at design-time, and then create an OnHelp event handler for it using the Object Inspector.

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770