Ignore:
Timestamp:
Jun 24, 2023, 12:33:35 PM (17 months ago)
Author:
chronos
Message:
  • Modified: Use TFormEx for all forms.
  • Modified: Test forms moved into Common package.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/xpascal/Packages/Common/FormEx.pas

    r227 r228  
    1111
    1212  TFormEx = class(TForm)
     13  private
     14    FCounter: Integer; static;
     15  public
    1316    PersistentForm: TPersistentForm; static;
    14     ThemeManager: TThemeManager;
    15     Translator: TTranslator;
     17    ThemeManager: TThemeManager; static;
     18    Translator: TTranslator; static;
    1619    procedure DoShow; override;
    1720    procedure DoCreate; override;
     
    2730procedure Register;
    2831begin
    29   RegisterClass(TFormEx);
     32  RegisterNoIcon([TFormEx]);
    3033end;
    3134
     
    3437procedure TFormEx.DoShow;
    3538begin
     39  inherited;
    3640  PersistentForm.Load(Self);
    37   inherited;
    3841end;
    3942
    4043procedure TFormEx.DoCreate;
    4144begin
    42   inherited;
    4345  if not Assigned(PersistentForm) then
    4446    PersistentForm := TPersistentForm.Create(nil);
     
    5254  Translator.TranslateComponentRecursive(Self);
    5355  ThemeManager.UseTheme(Self);
     56  Inc(FCounter);
     57  inherited;
    5458end;
    5559
     
    6266procedure TFormEx.DoDestroy;
    6367begin
    64   FreeAndNil(PersistentForm);
    65   FreeAndNil(ThemeManager);
    66   FreeAndNil(Translator);
     68  Dec(FCounter);
     69  if FCounter <= 0 then begin
     70    FreeAndNil(PersistentForm);
     71    FreeAndNil(ThemeManager);
     72    FreeAndNil(Translator);
     73  end;
    6774  inherited;
    6875end;
Note: See TracChangeset for help on using the changeset viewer.