Why not inherit a new component from your existing component, and make it handle the windows message. It can call the handling method of its ancestor and then fire its own event "EmbeddedButtonClick"
----- Original Message -----
Sent: Thursday, 21 November 2002 12:23
Subject: RE: [DUG]: [Q] Event Hooking.....

C,

My example was simple to illustrate the concept. I agree with what you have said however what I have to do in practice is a bit more complex. I'll explain here:

- A windows message arrives from a C++ DLL to an already existing component we use internally
- The above message will generate an event based on that message on that existing component
- I am developing a new component that makes use of the existing component to do some special processing based on this message

So I do not want to interfere with the notifcation event that the existing component generates as that may be used by a developer for other purposes. However I need to know when that message arrives so that I can take action in my new component. I do not want to have to rely on the developer having to make a method call into my component.

At 11:57 21/11/2002 +1300, you wrote:
Donovan,
 
Would it not be better to expose an OnClick event on your component itself instead of exposing your internal button?  You could call it OnButtonClick to differentiate it from any other internal control event.  This way, you can perform any code you want before/after you internally call Click on your embedded button.
 
IMHO, from a developer using your component, I would think logically of your component as a single control, not a collection of controls.
 
HTH,
 
Conor
-----Original Message-----
From: Donovan J. Edye [mailto:[EMAIL PROTECTED]]
Sent: Thursday, 21 November 2002 11:42 a.m.
To: Multiple recipients of list delphi
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.
----------------------------------------------------------------------

Reply via email to