unit MainModule;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  WindowsSize = record
   Left, Top, Width, Height:Integer;
  end;


  TForm1 = class(TForm)
    procedure FormShow(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormShow(Sender: TObject);
var
 ws:WindowsSize;
 fs:TFileStream;
begin
 if FileExists('size.dat') then
  begin
   fs:=TFileStream.Create('size.dat', fmOpenRead);
   fs.Read(ws, sizeof(ws));
   fs.Free;

   Left:=ws.Left;
   Top:=ws.Top;
   Width:=ws.Width;
   Height:=ws.Height;
  end;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
var
 ws:WindowsSize;
 f:TFileStream;
 Str:String;
begin
 ws.Left:=Left;
 ws.Top:=Top;
 ws.Width:=Width;
 ws.Height:=Height;

 f:=TFileStream.Create('size.dat', fmCreate);
 f.Write(ws, sizeof(ws));
 f.Free;
end;

end.
