Solved

How to override sub component events

Posted on 2000-04-17
2
332 Views
Last Modified: 2010-04-04
Delphi Problem:
I have a component consisting of a panel with a button on it. I want to be able to override the click event of the button.
PS
So far I can surface the button's  click event so so the user can insert code via the object inspector, and I can overide the panel's click event so I can put in my own code. But how to overide the sub components code myself?
 
0
Comment
Question by:robert_m78
2 Comments
 
LVL 2

Accepted Solution

by:
mullet_attack earned 50 total points
ID: 2725176
declare a private procedure in you component :

procedure ButtonClick(Sender:TObject);

in your obects constructor (or wherever you create the button, add the line :

MyButton.OnClick := Buttonclick;

You can do whatever you want in the implementation of the ButtonClick procedure

This doesn't override the buttons's click event, it merely specifies the proc to run when the event happens. ie using this code you can't still call the inherited Click to allow the user's code to run also.

To still be able to run the user's code, define an event (sounds like you already have), and in the ButtonClick proc do "if Assigned(MyButtonEvent) then DoButtonEvent(Self)"
0
 

Author Comment

by:robert_m78
ID: 2725199
Many thanks
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now