Ignore:
Timestamp:
Jul 20, 2018, 10:25:06 AM (6 years ago)
Author:
chronos
Message:
Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

    • Property svn:ignore
      •  

        old new  
        66compiled
        77heaptrclog.trc
         8LazFuck.dbg
  • trunk/Packages/Common/UPersistentForm.pas

    r81 r93  
    88
    99uses
    10   Classes, SysUtils, Forms, URegistry, LCLIntf, Registry, Controls, ComCtrls;
     10  Classes, SysUtils, Forms, URegistry, LCLIntf, Registry, Controls, ComCtrls,
     11  ExtCtrls;
    1112
    1213type
     
    2627    FormWindowState: TWindowState;
    2728    Form: TForm;
    28     DefaultFormWindowState: TWindowState;
    2929    procedure LoadFromRegistry(RegistryContext: TRegistryContext);
    3030    procedure SaveToRegistry(RegistryContext: TRegistryContext);
    3131    function CheckEntireVisible(Rect: TRect): TRect;
    3232    function CheckPartVisible(Rect: TRect; Part: Integer): TRect;
    33     procedure Load(Form: TForm; DefaultFormWindowState: TWindowState = wsNormal);
     33    procedure Load(Form: TForm; DefaultMaximized: Boolean = False);
    3434    procedure Save(Form: TForm);
    3535    constructor Create(AOwner: TComponent); override;
     
    7272  end;
    7373
     74  if (Control is TPanel) then begin
     75    with Form, TRegistryEx.Create do
     76    try
     77      RootKey := RegistryContext.RootKey;
     78      OpenKey(RegistryContext.Key + '\Forms\' + Form.Name + '\' + Control.Name, True);
     79      if (TPanel(Control).Align = alRight) or (TPanel(Control).Align = alLeft) then begin
     80        if ValueExists('Width') then
     81          TPanel(Control).Width := ReadInteger('Width');
     82      end;
     83      if (TPanel(Control).Align = alTop) or (TPanel(Control).Align = alBottom) then begin
     84        if ValueExists('Height') then
     85          TPanel(Control).Height := ReadInteger('Height');
     86      end;
     87    finally
     88      Free;
     89    end;
     90  end;
     91
    7492  if Control is TWinControl then begin
    7593    WinControl := TWinControl(Control);
     
    96114      for I := 0 to TListView(Control).Columns.Count - 1 do begin
    97115        WriteInteger('ColWidth' + IntToStr(I), TListView(Control).Columns[I].Width);
     116      end;
     117    finally
     118      Free;
     119    end;
     120  end;
     121
     122  if (Control is TPanel) then begin
     123    with Form, TRegistryEx.Create do
     124    try
     125      RootKey := RegistryContext.RootKey;
     126      OpenKey(RegistryContext.Key + '\Forms\' + Form.Name + '\' + Control.Name, True);
     127      if (TPanel(Control).Align = alRight) or (TPanel(Control).Align = alLeft) then begin
     128        WriteInteger('Width', TPanel(Control).Width);
     129      end;
     130      if (TPanel(Control).Align = alTop) or (TPanel(Control).Align = alBottom) then begin
     131        WriteInteger('Height', TPanel(Control).Height);
    98132      end;
    99133    finally
     
    135169      + FormRestoredSize.Top;
    136170    // Other state
    137     FormWindowState := TWindowState(ReadIntegerWithDefault('WindowState', Integer(DefaultFormWindowState)));
     171    FormWindowState := TWindowState(ReadIntegerWithDefault('WindowState', Integer(wsNormal)));
    138172  finally
    139173    Free;
     
    216250end;
    217251
    218 procedure TPersistentForm.Load(Form: TForm; DefaultFormWindowState: TWindowState = wsNormal);
     252procedure TPersistentForm.Load(Form: TForm; DefaultMaximized: Boolean = False);
    219253begin
    220254  Self.Form := Form;
    221   Self.DefaultFormWindowState := DefaultFormWindowState;
    222 
    223255  // Set default
    224256  FormNormalSize := Bounds((Screen.Width - Form.Width) div 2,
     
    230262
    231263  if not EqualRect(FormNormalSize, FormRestoredSize) or
    232     (FormWindowState = wsMaximized) then begin
     264    DefaultMaximized then begin
    233265    // Restore to maximized state
    234266    Form.WindowState := wsNormal;
Note: See TracChangeset for help on using the changeset viewer.