소스 검색

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

cobines 15 년 전
부모
커밋
ae1a3d2488
2개의 변경된 파일29개의 추가작업 그리고 5개의 파일을 삭제
  1. 27 3
      src/uclassesex.pas
  2. 2 2
      src/uglobs.pas

+ 27 - 3
src/uclassesex.pas

@@ -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.

+ 2 - 2
src/uglobs.pas

@@ -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.