dx15ti
asked on
Creatin Components At Runetime
How can I declare the onclick procedure of a self created component ?
Greetings!
Thomas
Greetings!
Thomas
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
ASKER