unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
TTestKlasse=class(TPersistent)
public
procedure LoadChild;
private
Child:TTestKlasse;
T1:
String;
published
Constructor create;
virtual;
destructor destroy;
override;
end;
TTestKlasse2=class(TTestKlasse)
public
List:TStringList;
T:
String;
published
constructor create;
override;
destructor destroy;
override;
end;
TTestKlasseClass =
class of TTestKlasse;
var
Form1: TForm1;
implementation
{$R *.dfm}
{ TTestKlasse2 }
constructor TTestKlasse2.create;
begin
List:=TstringList.create;
List.add('
Hallo');
T:='
Hallo';
inherited;
end;
destructor TTestKlasse2.destroy;
begin
List.free;
inherited;
end;
{ TTestKlasse }
constructor TTestKlasse.create;
begin
T1:='
Hallo von Test';
end;
destructor TTestKlasse.destroy;
begin
inherited;
end;
procedure TTestKlasse.LoadChild;
var TCC:TTestKlasseClass;
begin
TCC:=TTestKlasseClass(FindClass('
TTestKlasse2'));
Child:=TCC.create;
showmessage(TTestKlasse2(Child).T);
showmessage(self.T1);
showmessage(TTestKlasse2(Child).List.Text);
end;
procedure TForm1.Button1Click(Sender: TObject);
var TC:TTestKlasse;
begin
registerclass(TTestKlasse2);
TC:=TTestklasse.create;
TC.loadChild
end;
end.