Solved

How to override sub component events

Posted on 2000-04-17
2
334 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi OLE Error 8 93
code issue 8 97
Convert a string into a TDateTime 5 50
Firemonkey android show image from resource ? 1 30
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

930 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

11 Experts available now in Live!

Get 1:1 Help Now