Solved

Creating Own Events

Posted on 1997-04-09
1
161 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

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

867 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

22 Experts available now in Live!

Get 1:1 Help Now