Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

OnChange Custom Event in Delph win32

Posted on 2009-07-16
1
Medium Priority
?
281 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone 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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

609 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