ADD: Save session properties to session.ini

This commit is contained in:
Alexander Koblov 2009-04-17 20:55:48 +00:00
commit 33dcc7683d
4 changed files with 36 additions and 4 deletions

View file

@ -11,6 +11,7 @@ object frmOptions: TfrmOptions
OnDestroy = FormDestroy
OnShow = FormShow
Position = poScreenCenter
SessionProperties = 'Height;Width;WindowState'
ShowInTaskBar = stNever
LCLVersion = '0.9.26.3'
object Panel1: TPanel

View file

@ -413,6 +413,8 @@ end;
procedure TfrmOptions.FormCreate(Sender: TObject);
begin
// Initialize property storage
InitPropStorage(Self);
// Resize window for screen size if need
ResizeToScreen(Self);
// Localize Mouse selection mode ComboBox

View file

@ -28,7 +28,7 @@ unit uClassesEx;
interface
uses
Classes, RtlConsts, SysUtils, IniFiles;
Classes, RtlConsts, SysUtils, IniFiles, IniPropStorage;
type
{ TFileStreamEx class }
@ -57,11 +57,19 @@ type
private
FIniFileStream: TFileStreamEx;
public
constructor Create(const AFileName: String; Mode: Word = fmOpenReadWrite);
constructor Create(const AFileName: String; Mode: Word);
constructor Create(const AFileName: string; AEscapeLineFeeds : Boolean = False); override;
destructor Destroy; override;
procedure UpdateFile; override;
end;
{ TIniPropStorageEx }
TIniPropStorageEx = class(TCustomIniPropStorage)
protected
function IniFileClass: TIniFileClass; override;
end;
implementation
uses uOSUtils;
@ -132,7 +140,12 @@ begin
else
FIniFileStream:= TFileStreamEx.Create(AFileName, fmCreate);
inherited Create(FIniFileStream);
end;
end;
constructor TIniFileEx.Create(const AFileName: string; AEscapeLineFeeds: Boolean);
begin
Create(AFileName, fmOpenReadWrite);
end;
procedure TIniFileEx.UpdateFile;
begin
@ -147,4 +160,11 @@ begin
inherited Destroy;
end;
{ TIniPropStorageEx }
function TIniPropStorageEx.IniFileClass: TIniFileClass;
begin
Result:= TIniFileEx;
end;
end.

View file

@ -220,6 +220,7 @@ function LoadStringsFromFile(var list:TStringListEx; const sFileName:String):boo
procedure LoadDefaultHotkeyBindings;
procedure ResizeToScreen(Control:TControl; Increase: Boolean = False; Width:integer=1024; Height:integer=768);
procedure InitPropStorage(Owner: TComponent);
// for debugging only, can be removed
procedure dbgShowWindowPos(const pos: TControlPosition);
@ -313,6 +314,14 @@ begin
Control.Height:= NewH;
end;
procedure InitPropStorage(Owner: TComponent);
var
IniPropStorage: TIniPropStorageEx;
begin
IniPropStorage:= TIniPropStorageEx.Create(Owner);
IniPropStorage.IniFileName:= gpIniDir + 'session.ini';
end;
// for debugging only, can be removed
procedure dbgShowWindowPos(const pos: TControlPosition);
begin