var
Form1: TForm1;
cfg: TXMLConfig;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction);
begin
with cfg do
begin
SetValue('NormalLeft', Left);
SetValue('NormalTop', Top);
SetValue('NormalWidth', Width);
SetValue('NormalHeight', Height);
SetValue('RestoredLeft', RestoredLeft);
SetValue('RestoredTop', RestoredTop);
SetValue('RestoredWidth', RestoredWidth);
SetValue('RestoredHeight', RestoredHeight);
SetValue('WindowState', Integer(WindowState));
Flush;
Free;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
var
LastWindowState: TWindowState;
begin
cfg := TXMLConfig.Create(Self);
with cfg do
begin
FileName := ChangeFileExt(Application.ExeName, '.xml');
LastWindowState := TWindowState(GetValue('WindowState', Integer(WindowState)));
if LastWindowState = wsMaximized then
begin
WindowState := wsNormal;
BoundsRect := Bounds(
GetValue('RestoredLeft', RestoredLeft),
GetValue('RestoredTop', RestoredTop),
GetValue('RestoredWidth', RestoredWidth),
GetValue('RestoredHeight', RestoredHeight));
WindowState := wsMaximized;
end else
begin
WindowState := wsNormal;
BoundsRect := Bounds(
GetValue('NormalLeft', Left),
GetValue('NormalTop', Top),
GetValue('NormalWidth', Width),
GetValue('NormalHeight', Height));
end;
end;
end;