Registriert seit: 20. Jan 2006
Ort: Lübbecke
11.475 Beiträge
Delphi 12 Athens
|
AW: Event handler dynamisch setzen
20. Feb 2023, 23:29
Warum so kompiliziert?
Delphi-Quellcode:
program ex1;
{$APPTYPE CONSOLE}
{$R *.res}
uses
System.SysUtils,
System.classes;
type
TWrapper = class(TObject)
private
public
published
procedure Event(Sender: TObject);
end;
procedure TWrapper.Event(Sender: TObject);
begin
writeln('Event');
end;
var
sl: TStringlist;
wrapper: TWrapper;
begin
wrapper := TWrapper.Create;
try
sl := TStringlist.Create;
try
sl.OnChange := wrapper.Event;
sl.Add('foo');
finally
sl.Free;
end;
finally
wrapper.Free;
end;
end.
|