Board index » delphi » Help With Creating Context Sensitive Help

Help With Creating Context Sensitive Help

I am attempting to create a Context Sensitive Help file.  But, I am
having problems controlling the Application OnHelp event handler.  I
can't even get the example given for TApplications's OnHelp event handler
to work.  Can someone tell me what's wrong with the code below.  I keep
getting the error message:  "Error 26:  Type mismatch."

unit Temp;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs;

type
  TForm1 = class(TForm)
    OpenDialog1: TOpenDialog;
    procedure FormCreate(Sender: TObject);
    function AppHelp(Command: Word; Data: LongInt): Boolean;
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.FormCreate(Sender: TObject);
begin
    Application.OnHelp := AppHelp;              IT STOPS HERE!!!!!!
end;

function AppHelp(Command: Word; Data: LongInt): Boolean;
begin
   If OpenDialog1.Execute then
      Application.HelpFile := OpenDialog1.Filename;
end;

end.

Carolyn Burns
Systems Analyst/Programmer
Fred Hutchinson Cancer Research Center

 

Re:Help With Creating Context Sensitive Help


"Carolyn J. Burns" <cjbu...@cclink.fhcrc.org> wrote:

Quote
>I am attempting to create a Context Sensitive Help file.  But, I am
>having problems controlling the Application OnHelp event handler.  I
>can't even get the example given for TApplications's OnHelp event handler
>to work.  Can someone tell me what's wrong with the code below.  I keep
>getting the error message:  "Error 26:  Type mismatch."
>unit Temp;
>interface
>uses
>  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
>  Forms, Dialogs;
>type
>  TForm1 = class(TForm)
>    OpenDialog1: TOpenDialog;
>    procedure FormCreate(Sender: TObject);
>    function AppHelp(Command: Word; Data: LongInt): Boolean;
>  private
>    { Private declarations }
>  public
>    { Public declarations }
>  end;
>var
>  Form1: TForm1;
>implementation
>{$R *.DFM}
>procedure TForm1.FormCreate(Sender: TObject);
>begin
>    Application.OnHelp := AppHelp;          IT STOPS HERE!!!!!!
>end;
>function AppHelp(Command: Word; Data: LongInt): Boolean;
>begin
>   If OpenDialog1.Execute then
>      Application.HelpFile := OpenDialog1.Filename;
>end;
>end.

There is (nearly) nothing wrong with your code, but with the Delphi
helpfile.

In the object browser / unit Classes THelpEvent is defined as
THelpEvent = function(Word, Longint, var Boolean): Boolean;

So declare AppHelp as
function AppHelp(Command: Word; Data: LongInt; var Done: boolean):
   Boolean;
(and add "TForm1." to function AppHelp in the implementation part)
and the program will run.

Norbert Triebenbacher

Other Threads