Type
TDisplayMethod = procedure(const s: string) of object;
//------------------------------------------------------
TDeveloper = class
private
fName: string;
fOnNameChanged: TDisplayMethod;
procedure SetName(const Value: string);
constructor create;
published
property Name: string read fName write SetName;
property OnNameChanged: TDisplayMethod read fOnNameChanged write
fOnNameChanged;
end;
constructor TDeveloper.create;
begin
fName := 'warleyalex';
end;
procedure TDeveloper.SetName(const Value: string);
begin
if fName <> Value then
if Assigned(fOnNameChanged) then
fOnNameChanged('old name: ' + fName);
fOnNameChanged('new name: ' + Value);
fName := Value;
end;
procedure ValueDisplayer(const s: string);
begin
ShowMessage(s);
end;
procedure TForm1.W3Button8Click(Sender: TObject);
var
d: TDeveloper;
x : TDisplayMethod;
begin
d := TDeveloper.Create;
try
x := ValueDisplayer;
d.OnNameChanged := x;
d.Name := 'Sadan';
d.Name := 'BinLaden';
finally
d.Free;
end;
end;
|