UPD: Use class name instead of component name in "session.ini", so that every form instance has the same settings.

This commit is contained in:
cobines 2010-01-14 23:09:35 +00:00
commit ae1a3d2488
2 changed files with 29 additions and 5 deletions

View file

@ -77,19 +77,24 @@ type
TIniPropStorageEx = class(TCustomIniPropStorage)
private
FPercentSize: Integer;
function ChangeIdent(const Ident: String): String;
protected
function IniFileClass: TIniFileClass; override;
public
constructor Create(AOwner: TComponent); override;
procedure Restore; override;
function DoReadString(const Section, Ident, default: string): string; override;
procedure DoWriteString(const Section, Ident, Value: string); override;
property PercentSize: Integer read FPercentSize write FPercentSize;
end;
implementation
uses Forms, uOSUtils;
uses
Forms, uOSUtils, uDCUtils;
{ TFileStreamEx}
{ TFileStreamEx }
constructor TFileStreamEx.Create(const AFileName: UTF8String; Mode: Word);
begin
@ -252,4 +257,23 @@ begin
end;
end;
end.
function TIniPropStorageEx.DoReadString(const Section, Ident, default: string): string;
begin
Result := inherited DoReadString(Section, ChangeIdent(Ident), default);
end;
procedure TIniPropStorageEx.DoWriteString(const Section, Ident, Value: string);
begin
inherited DoWriteString(Section, ChangeIdent(Ident), Value);
end;
function TIniPropStorageEx.ChangeIdent(const Ident: String): String;
begin
// Change component name to class name.
if StrBegins(Ident, Owner.Name) then
Result := Owner.ClassName + Copy(Ident, 1 + Length(Owner.Name), MaxInt)
else
Result := Ident;
end;
end.

View file

@ -374,7 +374,7 @@ begin
begin
sWidth:= IntToStr(Monitor.Width);
sHeight:= IntToStr(Monitor.Height);
Result.IniSection:= Name + '(' + sWidth + 'x' + sHeight + ')';
Result.IniSection:= ClassName + '(' + sWidth + 'x' + sHeight + ')';
end;
end;
@ -908,4 +908,4 @@ initialization
finalization
DeInitGlobs;
end.
end.