Thanks Ben - works like a treat.

----- Original Message -----
From: "Ben Taylor" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Tuesday, April 24, 2001 1:58 PM
Subject: [DUG]: Basic OO/Delphi Question


> > In, say, Project A I have a form FormA with a label and caption.
> > When a change is made to some list or variable on FormX I want to
> > modify the FormA.label.caption
>
> have a look at this: (misc bits cut for clarity);
> formx publishes an event, called when fxNumber is set.
> forma has a public callback, same parameters as the event, that sets
> the label caption.
> at program startup (usually in the main form) there should be:
>  Formx.OnFxChange:=Forma.CallbackChange;
> but only after forma and formx have been instantiated.
>
> ----
>
> TFormA = class(TForm)
>   MyLabel: TLabel;
> public
>   procedure CallbackChange(Sender:TObject;const aValue:integer);
> end;
>
> procedure TFormA.CallbackChange(Sender: TObject; const aValue:
> integer);
> begin
>  MyLabel.Caption:=IntToStr(aValue);
> end;
>
> ----
>
> TfxChangeEvent = procedure(Sender:TObject;const aValue:integer) of
> object;
>
> TFormX = class(TForm)
> private
>   FfxNumber: integer;
>   FOnFxChange: TfxChangeEvent;
>   procedure SetfxNumber(const Value: integer);
> published
>   property fxNumber:integer read FfxNumber write SetfxNumber;
>   property OnFxChange:TfxChangeEvent read FOnFxChange Write
> FOnFxChange;
> end;
>
> procedure TFormX.SetfxNumber(const Value: integer);
> begin
>   FfxNumber := Value;
>   if Assigned(FOnFxChange) then
>    begin
>    FOnFxChange(Self,FfxNumber);
>    end;
> end;
>
>
>
>
> __________________________________________________
> Do You Yahoo!?
> Yahoo! Auctions - buy the things you want at great prices
> http://auctions.yahoo.com/
> --------------------------------------------------------------------------
-
>     New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
>                   Website: http://www.delphi.org.nz
> To UnSub, send email to: [EMAIL PROTECTED]
> with body of "unsubscribe delphi"
>

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"

Reply via email to