Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to override sub component events

Posted on 2000-04-17
2
Medium Priority
?
355 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 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses

722 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