Solved

Creating Own Events

Posted on 1997-04-09
1
153 Views
Last Modified: 2010-04-06
How do i do to write a own Event handler.
For example i have the folowing code.

TMyProc = Procedure ( Sender : TObject; Flag : byte );
TForm1 = Class ( TForm)  
  Private
  FmyProc : TMyProc;
  Public
  Property MyEvent : TMyProc read FMyProc write FMyProc;
end;

What i want to do is that when i write to the MyEvent i want the above Procedure MyProc to be executed. How do i do that.

Send answer to : martinar@algonet.se

Regards

Martin Arvidsson
0
Comment
Question by:martinar
1 Comment
 
LVL 3

Accepted Solution

by:
sperling earned 50 total points
ID: 1335261
First, append 'of object' to the type declaration.

TMyProc = Procedure ( Sender : TObject; Flag : byte ) of object;



TForm1 = Class ( TForm)
Private
  FmyProc : TMyProc;
Public
  Property MyEvent : TMyProc read FMyProc write FMyProc;
end;


Call the assigned event like this:

  if Assigned(FMyProc) then FMyProc(Self, SomeValue)


Regards,

Erik.

0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
This video discusses moving either the default database or any database to a new volume.
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

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