Solved

Creating Own Events

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

728 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