Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Product Manuals » Elevate Web Builder 3 Manual » Language Reference » Events |
<Type Name> = function/procedure ([<Parameters>])[: Type Name>] of object;
interface TStartEvent = procedure (StartingVehicle: TVehicle) of object; TVehicle = class private FOnStart: TStartEvent; public property OnStart: TStartEvent read FOnStart write FOnStart; procedure Start; end; implementation procedure TVehicle.Start; begin if Assigned(FOnStart) then FOnStart(Self); end;
interface TGarage = class private FVehicle: TVehicle; protected procedure DoVehicleStart(StartingVehicle: TVehicle); public constructor Create; override; destructor Destroy; override; end; implementation constructor TGarage.Create; begin inherited Create; FVehicle:=TVehicle.Create; FVehicle.OnStart:=DoVehicleStart; FVehicle.Start; end; destructor TGarage.Destroy; begin FVehicle.Free; inherited Destroy; end; procedure TGarage.DoVehicleStart(StartingVehicle: TVehicle); begin ShowMessage('Vehicle has been started'); end;
TGarage = class private FVehicle: TVehicle; protected procedure DoVehicleStart; public constructor Create; override; destructor Destroy; override; end;
constructor TGarage.Create; begin inherited Create; FVehicle:=TVehicle.Create; FVehicle.OnStart:=DoVehicleStart; // Compiler error here !!! FVehicle.Start; end;
constructor TGarage.Create; begin inherited Create; FVehicle:=TVehicle.Create; FVehicle.OnStart:=DoVehicleStart; FVehicle.Start; FVehicle.OnStart:=nil; // Clear event handler end;
procedure TVehicle.Start; begin if Assigned(FOnStart) then FOnStart(Self); end;
interface TStartEvent = procedure (StartingVehicle: TVehicle) of object; TVehicle = class(TComponent) private FOnStart: TStartEvent; public procedure Start; published property OnStart: TStartEvent read FOnStart write FOnStart; default; end; implementation procedure TVehicle.Start; begin if Assigned(FOnStart) then FOnStart(Self); end;
This web page was last updated on Thursday, November 16, 2023 at 10:39 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |