unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls,JvDesignUtils;
type TMeinTyp=(mt_Typ1,mt_Typ2,mt_Typ3);
type TMeinRecord=record
MyBoolean:Boolean;
Mystring:
string;
MyTyp:TMeinTyp;
end;
type
TForm6 =
class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
procedure SaveLayOutToFile(Filename:
string);
procedure LoadLayOutFromFile(Filename:
string);
procedure SaveForm;
end;
type TMyLabel=class (TLabel)
private
fmyboolean:Boolean;
fMyRecord:TMeinRecord;
public
procedure ZeigeDich;
published
property MyBoolean:Boolean
read fmyboolean
write fmyboolean;
property MyRecord:TMeinRecord
read fMyRecord
write fMyRecord;
end;
var
Form6: TForm6;
implementation
{$R *.dfm}
procedure TForm6.SaveForm;
var
fFile: TFileStream;
i: Integer;
begin
fFile := TFileStream.Create('
C:\Test.txt', fmCreate);
try
for i :=0
to self.ComponentCount-1
do
begin
fFile.WriteComponent(self.Components[i]);
end;
finally
fFile.Free;
end;
end;
procedure TForm6.Button1Click(Sender: TObject);
var
ALabel:TMyLabel;
begin
ALabel:=TMyLabel.Create(Self);
ALabel.Parent:=self;
ALabel.Left:=150;
ALabel.Top:=50;
// ALabel.MyRecord.MyTyp:=mt_Typ2;
ALabel.ZeigeDich;
end;
procedure TForm6.Button2Click(Sender: TObject);
begin
SaveLayOutToFile('
C:\Test2.txt');
end;
procedure TForm6.Button3Click(Sender: TObject);
begin
LoadLayOutFromFile('
C:\Test2.txt');
end;
procedure TForm6.SaveLayOutToFile(Filename:
string);
begin
DesignSaveComponentToFile(self, Filename);
end;
procedure TForm6.LoadLayOutFromFile(Filename:
string);
begin
DesignLoadComponentFromFile(self, FileName,
nil);
end;
{ TMyLabel }
procedure TMyLabel.ZeigeDich;
begin
case MyRecord.MyTyp
of
mt_Typ1: Caption:='
mt_Typ1';
mt_Typ2: Caption:='
mt_Typ2';
mt_Typ3: Caption:='
mt_Typ3';
end;
end;
initialization
registerclass(TMyLabel);
finalization
unregisterclass(TMyLabel);
end.