?
Solved

Creating Own Events

Posted on 1997-04-09
1
Medium Priority
?
185 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 100 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying 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

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…
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…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

762 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