Link to home
Start Free TrialLog in
Avatar of annlee
annlee

asked on

How to add a Published Event to a Form ?

I want to make a TMyForm,
and add it to my Repository.
So I can new a MyForm1 in my projects later.

But the Events declared in TMyForm don't appear
in the Object Inspector, why? how do I do ?

(Excuse me, I'm a Chinese, My English is poor,
if you don't understand me , pls discuss with me).
Avatar of Cesario Lababidi
Cesario Lababidi
Flag of Germany image

Avatar of Rossie
Rossie

Listening
Hi,

What you should do is first create the descendant of the form e.g. TMyForm.  Add all necessary properties and events to that class.  What you shouldn't do is drop components onto your descendant, because Delphi seems to have some problems with that.  Lets say you want to add a published event called MyEvent, you would have something like this :

...
type
  TMyForm = Class( TForm )
  private
    FMyEvent : TNotifyEvent;
  published
    property MyEvent : TNotifyEvent read FMyEvent write FMyEvent;
  end;

procedure Register;

Finally in the register method you should register your form with Delphi using the RegisterCustomModule.

Procedure Register;
begin
  RegisterCustomModule( TMyForm, TCustomModule );
end;

If you now open a TMyForm ( or descendant ) in Delphi, you should see you published event has been added.

Best regards,


Stefaan
Avatar of annlee

ASKER

Please explain the usage of the "RegisterCustomModule" procedure, OK?

I want to not only create this form, but also understand this theory .


What is the TCustomModule?
Why should I do this as you said ?
ASKER CERTIFIED SOLUTION
Avatar of Stefaan
Stefaan

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
annlee:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.