Link to home
Start Free TrialLog in
Avatar of dx15ti
dx15ti

asked on

Creatin Components At Runetime

How can I declare the onclick procedure of a self created component ?

Greetings!
Thomas
Avatar of dx15ti
dx15ti

ASKER

Edited text of question
ASKER CERTIFIED SOLUTION
Avatar of d003303
d003303

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
This is the way you can declare it. It doesn't work themn yet, it is just for the storage.

type
  TMyComp = class(TGraphicControl)
  private
    FOnClick : TNotifyEvent;
    ..
  published
    property OnClick : TNotifyEvent
      read FNotifyEvent
      write FNotifyEvent;
  end;

To make it work on an OnClick add the following:

You have to call the notifyevent the following way from one of the protected procedures of the base class:

if Assigned(FOnClick) then FOnClick(Self);

This code can be inside

MouseDown or MouseUp (don't forget to add the override directive and caslling the inherited procedures.

Regards Jacco

Oops just too late. I understood your question differently.
d003303 answered the runtime part of the question. I thought you wanted to declare an OnClick property in a custom component...

Good luck