Changeset 567 for Common/FormEx.pas
- Timestamp:
- Jun 30, 2023, 10:09:00 PM (16 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Common/FormEx.pas
r566 r567 4 4 5 5 uses 6 Classes, SysUtils, Forms, PersistentForm, Theme, Translator ;6 Classes, SysUtils, Forms, PersistentForm, Theme, Translator, ScaleDPI; 7 7 8 8 type … … 13 13 private 14 14 FCounter: Integer; static; 15 protected 16 procedure DoShow; override; 17 procedure DoCreate; override; 18 procedure DoClose(var CloseAction: TCloseAction); override; 19 procedure DoDestroy; override; 15 20 public 16 21 PersistentForm: TPersistentForm; static; 17 22 ThemeManager: TThemeManager; static; 18 23 Translator: TTranslator; static; 19 procedure DoShow; override; 20 procedure DoCreate; override; 21 procedure DoClose(var CloseAction: TCloseAction); override; 22 procedure DoDestroy; override; 24 ScaleDPI: TScaleDPI; static; 25 OwnsPersistentForm: Boolean; static; 26 OwnsThemeManager: Boolean; static; 27 OwnsTranslator: Boolean; static; 28 OwnsScaleDPI: Boolean; static; 23 29 end; 24 30 … … 43 49 procedure TFormEx.DoCreate; 44 50 begin 45 if not Assigned(PersistentForm) then 51 if not Assigned(PersistentForm) then begin 52 OwnsPersistentForm := True; 46 53 PersistentForm := TPersistentForm.Create(nil); 47 if not Assigned(ThemeManager) then 54 end; 55 if not Assigned(ThemeManager) then begin 56 OwnsThemeManager := True; 48 57 ThemeManager := TThemeManager.Create(nil); 58 end; 49 59 if not Assigned(Translator) then begin 50 60 Translator := TTranslator.Create(nil); 51 61 Translator.POFilesFolder := 'Languages'; 52 62 Translator.Language := Translator.Languages.SearchByCode(''); 63 OwnsTranslator := True; 53 64 end; 65 if not Assigned(ScaleDPI) then begin 66 OwnsScaleDPI := True; 67 ScaleDPI := TScaleDPI.Create(nil); 68 end; 69 54 70 Translator.TranslateComponentRecursive(Self); 55 71 ThemeManager.UseTheme(Self); … … 68 84 Dec(FCounter); 69 85 if FCounter <= 0 then begin 70 FreeAndNil(PersistentForm); 71 FreeAndNil(ThemeManager); 72 FreeAndNil(Translator); 86 if OwnsPersistentForm then begin 87 FreeAndNil(PersistentForm); 88 OwnsPersistentForm := False; 89 end; 90 if OwnsThemeManager then begin 91 FreeAndNil(ThemeManager); 92 OwnsThemeManager := False; 93 end; 94 if OwnsTranslator then begin 95 FreeAndNil(Translator); 96 OwnsTranslator := False; 97 end; 98 if OwnsScaleDPI then begin 99 FreeAndNil(ScaleDPI); 100 OwnsScaleDPI := False; 101 end; 73 102 end; 74 103 inherited;
Note:
See TracChangeset
for help on using the changeset viewer.