unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 =
class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button3Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
ComponentA : TComponent;
begin
ComponentA := TComponent.Create(self);
ComponentA.
Name := '
ComponentA';
end;
procedure TForm1.Button2Click(Sender: TObject);
var
ComponentB : TComponent;
begin
ComponentB := TComponent.Create(FindComponent('
ComponentA'));
ComponentB.
Name := '
ComponentB';
// ComponentB.setSubComponent(true);
end;
procedure TForm1.Button3Click(Sender: TObject);
var
FileStream : TFilestream;
StringStream : TStringStream;
StringList : TStringList;
begin
FileStream:=TFileStream.Create('
speichern-binaer.dat',fmCreate);
StringStream := TStringStream.Create('
');
Try
FileStream.WriteComponent(Form1);
FileStream.Position := 0;
ObjectBinaryToText(FileStream, StringStream);
StringList := TStringList.Create;
StringList.add(StringStream.DataString);
StringList.SaveToFile('
speichern-textform.txt');
Finally
FileStream.Free;
StringStream.Free;
end;
end;
end.