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
Solved

Creatin Components At Runetime

Posted on 1998-07-01
3
160 Views
Last Modified: 2010-08-05
How can I declare the onclick procedure of a self created component ?

Greetings!
Thomas
0
Comment
Question by:dx15ti
3 Comments
 

Author Comment

by:dx15ti
ID: 1356780
Edited text of question
0
 
LVL 4

Accepted Solution

by:
d003303 earned 100 total points
ID: 1356781
Yo,
you have to provide a TNotifyEvent typed method.

procedure Form1.RuntimeButtonClick(Sender : TObject);
begin
  // ...stuff
end;

procedure Form1.CreateRuntimeButton;
var RuntimeButton : TButton;
begin
  RuntimeButton := TButton.Create(Self);
  RuntimeButton.Parent := Self;
  RuntimeButton.OnClick := RuntimeButtonClick;
end;

Slash/d003303
0
 
LVL 10

Expert Comment

by:Jacco
ID: 1356782
This is the way you can declare it. It doesn't work themn yet, it is just for the storage.

type
  TMyComp = class(TGraphicControl)
  private
    FOnClick : TNotifyEvent;
    ..
  published
    property OnClick : TNotifyEvent
      read FNotifyEvent
      write FNotifyEvent;
  end;

To make it work on an OnClick add the following:

You have to call the notifyevent the following way from one of the protected procedures of the base class:

if Assigned(FOnClick) then FOnClick(Self);

This code can be inside

MouseDown or MouseUp (don't forget to add the override directive and caslling the inherited procedures.

Regards Jacco

Oops just too late. I understood your question differently.
d003303 answered the runtime part of the question. I thought you wanted to declare an OnClick property in a custom component...

Good luck

0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
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…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

861 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