Board index » delphi » OnActivate doesn't work

OnActivate doesn't work

Hello,

I made a simple program like this

unit Stamprn;

interface

uses
  SysUtils, Classes, Controls, Dialogs, StdCtrls, MakeDBF, DB, DBTables,
Forms;

procedure FormActivate;
procedure ExDBF ; export;

implementation

var  D : string;
     Form1  : TForm;
     Label1 : TLabel;

procedure ExDBF;
begin
  Form1 := TForm.Create(Form1);
  with Form1 do
  begin
   Left   := 200;
   Top    := 300;
   Height := 100;
   OnActivate := FormActivate;
  end;
  Label1 := TLabel.Create(nil);
  with Label1 do
  begin
   Left := 5;
   Top := 10;
   Caption := 'One moment S.V.P.';
   Parent := Form1;
  end;
  Form1.Showmodal;
end;

procedure FormActivate;
begin
  MakeExDBF;
  ExportDBF;
end;

My progam can't find the procedure FormActive but it is declared.
It gives an error on the row  "OnActivate := FormActivate;".

If I'm doing the same with an already declared Form wit the class method
and make the
FormActivate public, it's working perfectly.

It's possible to make a form without using a dfm-file, but why do I get
this error
"can't find procedure/refference ...."

Is there somebody who know's something about this.

John Kuiper

 

Re:OnActivate doesn't work


John,
OnActivate is of type TNotifyEvent, which is declared as
type TNotifyEvent = procedure (Sender: TObject) of object;

so I think that problem is that you are trying to aasign there a
procedure that is not 'of object', not a method of some object

Re:OnActivate doesn't work


Event handlers must be methods of an object.  You cannot assign a procedure
that is not a method to an event.  Try making your procedure a method of the
form.

--
Bill Todd
(Sorry but TeamB cannot answer questions received via email)
(Remove nospam from my email address to contact me for any other reason)

Other Threads