----- Original Message -----
Sent: Thursday, November 21, 2002 1:55
PM
Subject: Re: [DUG]: [Q] Event
Hooking.....
I've successfully used this method myself at
times. eg:
TMyClass = class(TAnAncestor)
private
FAnEventHandler :
TMyEvent;
protected
procedure
SetAnEvent(UsersEvent : TMyEvent);
function GetAnEvent:
TMyEvent;
procedure
TheRealButtonEvent(Sender : TObject);
public
property OnAnEvent : TMyEvent
read GetAnEvent write SetAnEvent;
end;
then...
procedure TMyClass.SetAnEvent(UsersEvent :
TMyEvent);
begin
FAnEventHandler :=
UsersEvent;
end;
function TMyClass.GetAnEvent:
TMyEvent;
begin
result :=
FAnEventHandler;
end;
procedure TMyClass.TheRealButtonEvent(Sender :
TObject);
begin
//do my stuff here (or
after)
if Assigned(FAnEventHandler)
then
FAnEventHandler(Sender);
end;
now the user never even reaches the real event
handler field and you are free to do what you need to.
Phil.
----- Original Message -----
Sent: Thursday, November 21, 2002 12:43
PM
Subject: Re: [DUG]: [Q] Event
Hooking.....
You could handle that by having a Set procedure
for your event field that holds on the users handler.
Phil.
----- Original Message -----
Sent: Thursday, November 21, 2002
11:57 AM
Subject: Re: [DUG]: [Q] Event
Hooking.....
P,
And what happens when the user has no event
assigned when the app starts and then during program operation sets an
event handler in code?
At 11:54 21/11/2002 +1300, you wrote:
At
runtime, you can check to see if the user has assigned an event handler
to the button and then internally store their handler and call after
your code.
Phil.
- ----- Original Message -----
- From: Donovan J.
Edye
- To: Multiple recipients
of list delphi
- Sent: Thursday, November 21, 2002 11:42 AM
- Subject: [DUG]: [Q] Event Hooking.....
- G'Day,
- I was just curious about some approaches to achieve responding to
the event of an embedded component in my component. Clear as mud? An
example:
- Lets say I have a component MyComponent that has a published
property MyButton : TButton. Now I want to take some action when the
user clicks the button assigned to MyButton. However any code that
they have assigned to the click event for the button must also be
fired.
- So basically I want to transparently hook the OnClick event. The
only way I can think of doing this is by responding to the apropriate
CN_*, CM_* message. Is there another way to do this? If not what
messages should I be looking at responding to?
- -- Donovan
- ----------------------------------------------------------------------
- Donovan J. Edye [www.edye.wattle.id.au]
- Namadgi Systems [www.namsys.com.au]
- Voice: +61 2 6285-3460
- Fax: +61 2 6285-3459
- TVisualBasic = Class(None);
- Heard just before the 'Big Bang': "...Uh Oh...."
- ----------------------------------------------------------------------
- GXExplorer [http://www.gxexplorer.org] Freeware Windows
Explorer
- replacement. Also includes freeware delphi windows explorer
components.
- ----------------------------------------------------------------------
--
Donovan
----------------------------------------------------------------------
Donovan J. Edye [www.edye.wattle.id.au]
Namadgi Systems [www.namsys.com.au]
Voice: +61 2 6285-3460
Fax: +61 2 6285-3459
TVisualBasic =
Class(None);
Heard just before the 'Big Bang': "...Uh Oh...."
----------------------------------------------------------------------
GXExplorer [http://www.gxexplorer.org] Freeware Windows Explorer
replacement. Also includes freeware
delphi windows explorer components.
----------------------------------------------------------------------