?
Solved

OnChange Custom Event in Delph win32

Posted on 2009-07-16
1
Medium Priority
?
274 Views
Last Modified: 2012-05-07
type
  TStatus   =  (NEW, ACTIVE, NOT_ACTIVE);

  type TDoFirstEvent = procedure (Sender: TObject) of object;

private
FOnChange : TDoFirstEvent;
FTypeStatus : TStatus;
//
published
property OnChange :  TDoFirstEvent read FOnChange write FOnChange;

// Dispatch method
procedure TBase.DoChange;
begin
if (Assigned (FOnChange) and (FTypeStatus = NEW))  then
begin
   sleep(500);
   FOnChange(Self);
end;
end

A Form contains an object of type TBase and in myform.create I do:

OnChange := DoFirst;

// DoFirst is an procedure of TDoFirstEvent type

My goal is to call DoFirst everytime OnChange is set and
FTypeStatus is NEW. It doesn't work, what is wrong in my approach?
:-(
0
Comment
Question by:jaja2005
[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 11

Accepted Solution

by:
dougaug earned 2000 total points
ID: 24869270
Hi,

in the code above, you aren't calling DoFirst and not triggering the OnChange event in any moment. he fact of assigning DoFirst method to OnChange property doesn't call the DoChange method.

If you want to call DoFirst, you should first assign it to OnChange property (as you've done) and in other part of your code you should call DoChange method.

Example:

procedure TBase.SetPropertyString(Value: String);
begin
  if PropertyString <> 'Value' then
  begin
     PropertyString := Value;
     DoChange;
  end
end;
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month8 days, 14 hours left to enroll

764 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