Solved

OnChange Custom Event in Delph win32

Posted on 2009-07-16
1
242 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
1 Comment
 
LVL 11

Accepted Solution

by:
dougaug earned 500 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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
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…
This video discusses moving either the default database or any database to a new volume.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 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

18 Experts available now in Live!

Get 1:1 Help Now