unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, StatusBarEx, Menus, StdCtrls;
type
TForm1 =
class(TForm)
MainMenu1: TMainMenu;
Datei1: TMenuItem;
Beenden1: TMenuItem;
SB: TStatusBarEx;
ffnen1: TMenuItem;
Memo1: TMemo;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
OpenDialog: TOpenDialog;
procedure Beenden1Click(Sender: TObject);
procedure FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
procedure FormCreate(Sender: TObject);
procedure ffnen1Click(Sender: TObject);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
constructor Create(aOwner: TComponent);
override;
end;
var
Form1: TForm1;
implementation
uses Utils1;
{$R *.DFM}
procedure TForm1.Beenden1Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
var
fs: TFilestream;
FFilename :
String;
begin
FFilename:=ApplicationPath+'
controls.sav';
fs:= TFilestream.Create(FFilename, fmCreate);
try
fs.WriteComponent(self);
finally
fs.free;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
WriteToStatusBar(SB,'
Writecomponent Test',0);
end;
procedure TForm1.ffnen1Click(Sender: TObject);
begin
If Not Opendialog.Execute
then Exit;
Memo1.Lines.LoadFromFile(Opendialog.Filename);
end;
constructor TForm1.Create(aOwner: TComponent);
var
fs: TFileStream;
FFilename :
String;
begin
FFilename:=ApplicationPath+'
controls.sav';
if FileExists(FFilename)
then
begin
CreateNew(aOwner);
// Hier ist der Trick
fs:= TFileStream.Create(FFilename, fmOpenread
or fmShareDenyWrite);
try
fs.ReadComponent(self);
finally
fs.free;
end;
end
else
inherited Create(aOwner);
end;
end.