Changeset 123 for trunk


Ignore:
Timestamp:
Nov 26, 2016, 11:33:19 AM (8 years ago)
Author:
chronos
Message:
  • Added: Remember width of list view columns after closing the application.
Location:
trunk
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Forms/UFormAbout.lfm

    r115 r123  
    1313  object LabelAppName: TLabel
    1414    Left = 20
    15     Height = 54
     15    Height = 55
    1616    Top = 20
    1717    Width = 433
     
    2525  object LabelDescription: TLabel
    2626    Left = 20
    27     Height = 40
    28     Top = 94
     27    Height = 48
     28    Top = 95
    2929    Width = 433
    3030    Align = alTop
     
    4646  object LabelContent: TLabel
    4747    Left = 20
    48     Height = 20
    49     Top = 154
     48    Height = 24
     49    Top = 163
    5050    Width = 433
    5151    Align = alTop
     
    7474    EmailContact = 'robie@centrum.cz'
    7575    AppName = 'Acronym Decoder'
    76     ReleaseDate = 42676
     76    ReleaseDate = 42700
    7777    RegistryKey = '\Software\'
    7878    RegistryRoot = rrKeyCurrentUser
  • trunk/Forms/UFormAcronyms.lfm

    r109 r123  
    77  ClientHeight = 558
    88  ClientWidth = 740
     9  OnClose = FormClose
    910  OnCreate = FormCreate
    1011  OnShow = FormShow
     
    3132      item
    3233        Caption = 'Categories'
    33         Width = 305
     34        Width = 312
    3435      end>
    3536    MultiSelect = True
  • trunk/Forms/UFormAcronyms.pas

    r104 r123  
    3636    procedure ARemoveExecute(Sender: TObject);
    3737    procedure ASelectAllExecute(Sender: TObject);
     38    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    3839    procedure FormCreate(Sender: TObject);
    3940    procedure FormShow(Sender: TObject);
     
    110111procedure TFormAcronyms.FormShow(Sender: TObject);
    111112begin
     113  Core.PersistentForm1.Load(Self);
    112114  ListViewFilter1.UpdateFromListView(ListViewAcronyms);
    113115  UpdateAcronymsList;
     
    223225end;
    224226
     227procedure TFormAcronyms.FormClose(Sender: TObject; var CloseAction: TCloseAction
     228  );
     229begin
     230  Core.PersistentForm1.Save(Self);
     231end;
     232
    225233procedure TFormAcronyms.FormCreate(Sender: TObject);
    226234var
  • trunk/Forms/UFormCategories.lfm

    r109 r123  
    77  ClientHeight = 429
    88  ClientWidth = 784
     9  OnClose = FormClose
    910  OnCreate = FormCreate
    1011  OnShow = FormShow
     
    2526      item
    2627        Caption = 'Used count'
    27         Width = 440
     28        Width = 456
    2829      end>
    2930    MultiSelect = True
  • trunk/Forms/UFormCategories.pas

    r104 r123  
    3333    procedure ARemoveExecute(Sender: TObject);
    3434    procedure ASelectAllExecute(Sender: TObject);
     35    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    3536    procedure FormCreate(Sender: TObject);
    3637    procedure FormShow(Sender: TObject);
     
    6970procedure TFormCategories.FormShow(Sender: TObject);
    7071begin
     72  Core.PersistentForm1.Load(Self);
    7173  UpdateList;
    7274  Core.ScaleDPI1.ScaleControl(ToolBar1, Core.ScaleDPI1.DesignDPI);
     
    126128end;
    127129
     130procedure TFormCategories.FormClose(Sender: TObject;
     131  var CloseAction: TCloseAction);
     132begin
     133  Core.PersistentForm1.Save(Self);
     134end;
     135
    128136procedure TFormCategories.FormCreate(Sender: TObject);
    129137var
  • trunk/Forms/UFormImportFormat.lfm

    r109 r123  
    77  ClientHeight = 439
    88  ClientWidth = 629
     9  OnClose = FormClose
    910  OnCreate = FormCreate
    1011  OnShow = FormShow
     
    3334  object Label1: TLabel
    3435    Left = 20
    35     Height = 25
     36    Height = 24
    3637    Top = 53
    37     Width = 51
     38    Width = 56
    3839    Caption = 'Name:'
    3940    ParentColor = False
     
    4142  object EditName: TEdit
    4243    Left = 179
    43     Height = 33
     44    Height = 34
    4445    Top = 48
    4546    Width = 426
     
    4950  object Label8: TLabel
    5051    Left = 20
    51     Height = 25
     52    Height = 24
    5253    Top = 90
    53     Width = 86
     54    Width = 97
    5455    Caption = 'Block start:'
    5556    ParentColor = False
     
    5758  object EditBlockStart: TEdit
    5859    Left = 179
    59     Height = 33
     60    Height = 34
    6061    Top = 85
    6162    Width = 426
     
    6566  object Label9: TLabel
    6667    Left = 20
    67     Height = 25
     68    Height = 24
    6869    Top = 130
    69     Width = 81
     70    Width = 89
    7071    Caption = 'Block end:'
    7172    ParentColor = False
     
    7374  object EditBlockEnd: TEdit
    7475    Left = 179
    75     Height = 33
     76    Height = 34
    7677    Top = 125
    7778    Width = 426
     
    104105      item
    105106        Caption = 'Repetition'
    106         Width = 100
     107        Width = 165
    107108      end>
    108109    OwnerData = True
     
    117118  object Label2: TLabel
    118119    Left = 20
    119     Height = 25
     120    Height = 24
    120121    Top = 157
    121     Width = 82
     122    Width = 92
    122123    Caption = 'Item rules:'
    123124    ParentColor = False
     
    125126  object Label3: TLabel
    126127    Left = 20
    127     Height = 25
     128    Height = 24
    128129    Top = 13
    129     Width = 42
     130    Width = 45
    130131    Caption = 'Type:'
    131132    ParentColor = False
     
    133134  object ComboBoxType: TComboBox
    134135    Left = 179
    135     Height = 33
     136    Height = 38
    136137    Top = 13
    137138    Width = 197
    138     ItemHeight = 25
     139    ItemHeight = 0
    139140    Items.Strings = (
    140141      'Text parse HTTP'
  • trunk/Forms/UFormImportFormat.pas

    r96 r123  
    4343    procedure AMoveUpExecute(Sender: TObject);
    4444    procedure ARemoveExecute(Sender: TObject);
     45    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    4546    procedure FormCreate(Sender: TObject);
    4647    procedure FormShow(Sender: TObject);
     
    151152end;
    152153
     154procedure TFormImportFormat.FormClose(Sender: TObject;
     155  var CloseAction: TCloseAction);
     156begin
     157  Core.PersistentForm1.Save(Self);
     158end;
     159
    153160procedure TFormImportFormat.FormCreate(Sender: TObject);
    154161begin
     
    160167procedure TFormImportFormat.FormShow(Sender: TObject);
    161168begin
     169  Core.PersistentForm1.Load(Self);
    162170  ReloadList;
    163171end;
  • trunk/Forms/UFormImportFormats.lfm

    r109 r123  
    77  ClientHeight = 414
    88  ClientWidth = 591
     9  OnClose = FormClose
    910  OnCreate = FormCreate
    1011  OnShow = FormShow
     
    2122      item
    2223        Caption = 'Name'
    23         Width = 557
     24        Width = 563
    2425      end>
    2526    MultiSelect = True
  • trunk/Forms/UFormImportFormats.pas

    r104 r123  
    3030    procedure AModifyExecute(Sender: TObject);
    3131    procedure ARemoveExecute(Sender: TObject);
     32    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    3233    procedure FormCreate(Sender: TObject);
    3334    procedure FormShow(Sender: TObject);
     
    103104procedure TFormImportFormats.FormShow(Sender: TObject);
    104105begin
     106  Core.PersistentForm1.Load(Self);
    105107  UpdateList;
    106108  Core.ScaleDPI1.ScaleControl(ToolBar1, Core.ScaleDPI1.DesignDPI);
     
    177179end;
    178180
     181procedure TFormImportFormats.FormClose(Sender: TObject;
     182  var CloseAction: TCloseAction);
     183begin
     184  Core.PersistentForm1.Save(Self);
     185end;
     186
    179187procedure TFormImportFormats.FormCreate(Sender: TObject);
    180188var
  • trunk/Forms/UFormImportSource.lfm

    r109 r123  
    77  ClientHeight = 459
    88  ClientWidth = 620
     9  OnClose = FormClose
    910  OnCreate = FormCreate
    1011  OnShow = FormShow
     
    1314  object EditName: TEdit
    1415    Left = 135
    15     Height = 33
     16    Height = 34
    1617    Top = 10
    1718    Width = 471
     
    2122  object Label1: TLabel
    2223    Left = 10
    23     Height = 25
     24    Height = 24
    2425    Top = 9
    25     Width = 51
     26    Width = 56
    2627    Caption = 'Name:'
    2728    ParentColor = False
     
    2930  object Label2: TLabel
    3031    Left = 10
    31     Height = 25
     32    Height = 24
    3233    Top = 49
    33     Width = 94
     34    Width = 101
    3435    Caption = 'Source URL:'
    3536    ParentColor = False
     
    3738  object EditURL: TEdit
    3839    Left = 136
    39     Height = 33
     40    Height = 34
    4041    Top = 49
    4142    Width = 350
     
    6566  object Label3: TLabel
    6667    Left = 10
    67     Height = 25
     68    Height = 24
    6869    Top = 96
    69     Width = 100
     70    Width = 108
    7071    Caption = 'Data format:'
    7172    ParentColor = False
     
    7374  object ComboBox1: TComboBox
    7475    Left = 135
    75     Height = 33
     76    Height = 38
    7677    Top = 91
    7778    Width = 350
    7879    Anchors = [akTop, akLeft, akRight]
    79     ItemHeight = 25
     80    ItemHeight = 0
    8081    Style = csDropDownList
    8182    TabOrder = 2
     
    9394  object CheckBoxEnabled: TCheckBox
    9495    Left = 10
    95     Height = 29
     96    Height = 28
    9697    Top = 128
    97     Width = 93
     98    Width = 92
    9899    Caption = 'Enabled'
    99100    TabOrder = 4
     
    101102  object Label4: TLabel
    102103    Left = 10
    103     Height = 25
     104    Height = 24
    104105    Top = 160
    105     Width = 88
     106    Width = 96
    106107    Caption = 'Categories:'
    107108    ParentColor = False
     
    116117    MultiSelect = True
    117118    PopupMenu = PopupMenuCategory
    118     ScrollWidth = 358
     119    ScrollWidth = 469
    119120    TabOrder = 5
     121    TopIndex = -1
    120122  end
    121123  object Button1: TButton
     
    144146  object Label5: TLabel
    145147    Left = 10
    146     Height = 25
     148    Height = 24
    147149    Top = 352
    148     Width = 88
     150    Width = 97
    149151    Caption = 'User name:'
    150152    ParentColor = False
     
    152154  object Label6: TLabel
    153155    Left = 305
    154     Height = 25
     156    Height = 24
    155157    Top = 351
    156     Width = 80
     158    Width = 87
    157159    Caption = 'Password:'
    158160    ParentColor = False
     
    160162  object EditUserName: TEdit
    161163    Left = 136
    162     Height = 33
     164    Height = 34
    163165    Top = 351
    164166    Width = 153
     
    167169  object EditPassword: TEdit
    168170    Left = 436
    169     Height = 33
     171    Height = 34
    170172    Top = 351
    171173    Width = 153
  • trunk/Forms/UFormImportSource.pas

    r96 r123  
    4444    procedure ButtonOpenURLClick(Sender: TObject);
    4545    procedure ButtonShowFormatClick(Sender: TObject);
     46    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    4647    procedure FormCreate(Sender: TObject);
    4748    procedure FormShow(Sender: TObject);
     
    8990end;
    9091
     92procedure TFormImportSource.FormClose(Sender: TObject;
     93  var CloseAction: TCloseAction);
     94begin
     95  Core.PersistentForm1.Save(Self);
     96end;
     97
    9198procedure TFormImportSource.FormCreate(Sender: TObject);
    9299begin
     
    96103procedure TFormImportSource.FormShow(Sender: TObject);
    97104begin
     105  Core.PersistentForm1.Load(Self);
    98106  UpdateInterface;
    99107end;
  • trunk/Forms/UFormImportSources.lfm

    r109 r123  
    77  ClientHeight = 414
    88  ClientWidth = 812
     9  OnClose = FormClose
    910  OnCreate = FormCreate
    1011  OnShow = FormShow
     
    7273      item
    7374        Caption = 'Date'
    74         Width = 100
     75        Width = 114
    7576      end>
    7677    MultiSelect = True
  • trunk/Forms/UFormImportSources.pas

    r104 r123  
    4444    procedure AProcessExecute(Sender: TObject);
    4545    procedure ARemoveExecute(Sender: TObject);
     46    procedure FormClose(Sender: TObject; var CloseAction: TCloseAction);
    4647    procedure FormCreate(Sender: TObject);
    4748    procedure FormShow(Sender: TObject);
     
    171172procedure TFormImportSources.FormShow(Sender: TObject);
    172173begin
     174  Core.PersistentForm1.Load(Self);
    173175  UpdateList;
    174176  Core.ScaleDPI1.ScaleControl(ToolBar1, Core.ScaleDPI1.DesignDPI);
     
    337339end;
    338340
     341procedure TFormImportSources.FormClose(Sender: TObject;
     342  var CloseAction: TCloseAction);
     343begin
     344  Core.PersistentForm1.Save(Self);
     345end;
     346
    339347procedure TFormImportSources.FormCreate(Sender: TObject);
    340348var
  • trunk/Packages/Common/UPersistentForm.pas

    r3 r123  
    88
    99uses
    10   Classes, SysUtils, Forms, URegistry, LCLIntf, Registry;
     10  Classes, SysUtils, Forms, URegistry, LCLIntf, Registry, Controls, ComCtrls;
    1111
    1212type
     
    1919    FMinVisiblePart: Integer;
    2020    FRegistryContext: TRegistryContext;
     21    procedure LoadControl(Control: TControl);
     22    procedure SaveControl(Control: TControl);
    2123  public
    2224    FormNormalSize: TRect;
     
    4951
    5052{ TPersistentForm }
     53
     54procedure TPersistentForm.LoadControl(Control: TControl);
     55var
     56  I: Integer;
     57  WinControl: TWinControl;
     58  Count: Integer;
     59begin
     60  if Control is TListView then begin
     61    with Form, TRegistryEx.Create do
     62    try
     63      RootKey := RegistryContext.RootKey;
     64      OpenKey(RegistryContext.Key + '\Forms\' + Form.Name + '\' + Control.Name, True);
     65      for I := 0 to TListView(Control).Columns.Count - 1 do begin
     66        if ValueExists('ColWidth' + IntToStr(I)) then
     67          TListView(Control).Columns[I].Width := ReadInteger('ColWidth' + IntToStr(I));
     68      end;
     69    finally
     70      Free;
     71    end;
     72  end;
     73
     74  if Control is TWinControl then begin
     75    WinControl := TWinControl(Control);
     76    if WinControl.ControlCount > 0 then begin
     77      for I := 0 to WinControl.ControlCount - 1 do begin
     78        if WinControl.Controls[I] is TControl then begin
     79          LoadControl(WinControl.Controls[I]);
     80        end;
     81      end;
     82    end;
     83  end;
     84end;
     85
     86procedure TPersistentForm.SaveControl(Control: TControl);
     87var
     88  I: Integer;
     89  WinControl: TWinControl;
     90begin
     91  if Control is TListView then begin
     92    with Form, TRegistryEx.Create do
     93    try
     94      RootKey := RegistryContext.RootKey;
     95      OpenKey(RegistryContext.Key + '\Forms\' + Form.Name + '\' + Control.Name, True);
     96      for I := 0 to TListView(Control).Columns.Count - 1 do begin
     97        WriteInteger('ColWidth' + IntToStr(I), TListView(Control).Columns[I].Width);
     98      end;
     99    finally
     100      Free;
     101    end;
     102  end;
     103
     104  if Control is TWinControl then begin
     105      WinControl := TWinControl(Control);
     106      if WinControl.ControlCount > 0 then begin
     107        for I := 0 to WinControl.ControlCount - 1 do begin
     108          if WinControl.Controls[I] is TControl then begin
     109            SaveControl(WinControl.Controls[I]);
     110          end;
     111        end;
     112      end;
     113    end;
     114end;
    51115
    52116procedure TPersistentForm.LoadFromRegistry(RegistryContext: TRegistryContext);
     
    181245      Form.BoundsRect := FormNormalSize;
    182246  end;
     247  LoadControl(Form);
    183248end;
    184249
     
    191256  FormWindowState := Form.WindowState;
    192257  SaveToRegistry(RegistryContext);
     258  SaveControl(Form);
    193259end;
    194260
Note: See TracChangeset for help on using the changeset viewer.