Solved

How to override sub component events

Posted on 2000-04-17
2
352 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
Suggested Courses
Course of the Month8 days, 13 hours left to enroll

617 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