• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 185
  • Last Modified:

Component design...help....

Hi all,

I'am basically writing a component which has the instance of another component as it private member. The component which is getting instantiated has an Event.. say OnFire()... My first objective is to have the Onfire event
in the new component and whatever data which is getting arrived on onFire event(private member compone.) it should be redirected to the new components method. so I cooly did this  TNewData = procedure(sender:TObject;data : Pchar);
    FonData : TOndata;

    property RevisedFire : TNewData read FOnData write FOnData;

   In the create I say

     RevisedFire := Instantiatedcomponent.OnFire;

The problem I face is that, the event is not getting fired in my
current component. The problem I found is the following statement in
my olf component(i.e., Onfire())

     if assigned(OnFire) then Onfire(self, data);

since the Onfire event is not mapped, if I'am not wrong(method pointer is nil this event is not getting fired)

  How to Assign the Onfire event from my method so that when the event
gets triggered in Instantiated compoenent, the data should get redirected to my new components event?

do we have any active faq about comp. design?...any sites please

Please Help me out...

Thanks in advance


1 Solution
This line:

RevisedFire := Instantiatedcomponent.OnFire;

Should read:

Instantiatedcomponent.OnFire := NewOnFireMethod;

Where NewOnFireMethod is a method of your new component. In this method you can do this:

procedure TMyComponent.NewOnFireMethod(Sender : Tobject);

  if assigned(RevisedFire) then RevisedFire(Sender);

Here is a page with a whole bunch of FAQs you may be interested in:



I think this is what you need:

Instantiatedcomponent.OnFire := RevisedFire;
rjaganAuthor Commented:
Hi Raymond,
    Thanks a lot for the immediate reply. I will try this
stuff and update you asap. So using this solution, its certainly not necessary to map the Instantiatedcomponent.Onfire method ...but just point that
method to my new method..Is that right..

So this code If Assigned(OnFire) in instantiated comp. will
work cool..

Thanks again...


Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Your instantiaed component should still do this:

     if assigned(OnFire) then Onfire(self, data);

because it needs to check it's event is valid. You need to do the similar check in the new component because that too might not be set (ie: this

  if assigned(RevisedFire) then RevisedFire(Sender);



rjaganAuthor Commented:
Hi Raymond,
     That worked really cool...Thanks a lot :-).The site
is also good. But you see...I'am expecting a complete
faq in digest form to read about comp. design and things related to that offline..

I would also like to thank Epsylon also

Once more...thanks for the help..

This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects the problem and the expert will now receive these points; points verified.

Please click on your Member Profile and select "View Question History" to navigate through any open or locked questions you may have to update and finalize them.  If you are an EE Pro user, you can also choose Power Search to find all your open questions.

This is the Community Support link, if help is needed, along with the link to All Topics which reflects many TAs recently added.


For experts interesting in helping the cleanup effort in their respective TAs, this link please:
Thank you,
Moderator @ Experts Exchange
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Tackle projects and never again get stuck behind a technical roadblock.
Join Now