unit Main;

interface

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

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

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.LoadProgParam;
var
 FIniFile: TRegIniFile;
begin
 FIniFile := TRegIniFile.Create('Software');
 FIniFile.OpenKey('VR',true);
 FIniFile.OpenKey('VR-Online',true);
 Width:=FIniFile.ReadInteger('Option', 'Width', 600);
 Height:=FIniFile.ReadInteger('Option', 'Heigth', 400);
 Left:=FIniFile.ReadInteger('Option', 'Left', 10);
 Top:=FIniFile.ReadInteger('Option', 'Top', 10);
 WindowState:=TWindowState(FIniFile.ReadInteger('Option', 'WinState', 2));
 FIniFile.Free;
end;
                                      
procedure TForm1.FormShow(Sender: TObject);
begin
 LoadProgParam;
end;

procedure TForm1.SaveProgParam;
var
 FIniFile: TRegIniFile;
begin
 FIniFile := TRegIniFile.Create('Software');
 FIniFile.OpenKey('VR',true);
 FIniFile.OpenKey('VR-Online',true);
 if WindowState=wsNormal then
  begin
   FIniFile.WriteInteger('Option', 'Width', Width);
   FIniFile.WriteInteger('Option', 'Heigth', Height);
   FIniFile.WriteInteger('Option', 'Left', Left);
   FIniFile.WriteInteger('Option', 'Top', Top);
  end;
 FIniFile.WriteInteger('Option', 'WinState', Integer(WindowState));
 FIniFile.Free;
end;

procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
 SaveProgParam;
end;

procedure TForm1.OkButtonClick(Sender: TObject);
begin
 Close;
end;

end.
