Changeset 104 for trunk/UCore.pas


Ignore:
Timestamp:
Oct 11, 2016, 9:49:16 AM (8 years ago)
Author:
chronos
Message:
  • Added: DPI scaling for icons and toolbars.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UCore.pas

    r99 r104  
    77uses
    88  Classes, SysUtils, FileUtil, UAcronym, UCoolTranslator, UPersistentForm,
    9   UJobProgressView, Forms, Controls, LazFileUtils;
     9  UJobProgressView, UScaleDPI, Forms, Controls, LazFileUtils, URegistry,
     10  Registry;
    1011
    1112type
     
    1718    JobProgressView1: TJobProgressView;
    1819    PersistentForm1: TPersistentForm;
     20    ScaleDPI1: TScaleDPI;
    1921    procedure CoolTranslator1Translate(Sender: TObject);
    2022    procedure DataModuleCreate(Sender: TObject);
     
    2224  private
    2325    FAlwaysOnTop: Boolean;
     26    StoredDimension: TControlDimension;
    2427    procedure SetAlwaysOnTop(AValue: Boolean);
    2528    function FindFirstNonOption: string;
     
    3336    procedure LoadConfig;
    3437    procedure SaveConfig;
     38    procedure ScaleDPI;
    3539    property AlwaysOnTop: Boolean read FAlwaysOnTop write SetAlwaysOnTop;
    3640  end;
     
    3842var
    3943  Core: TCore;
     44
     45const
     46  DefaultRegKey = '\Software\Chronosoft\Acronym Decoder';
     47
    4048
    4149implementation
     
    5563  InitializeStarted := False;
    5664  InitializeFinished := False;
     65  StoredDimension := TControlDimension.Create;
    5766end;
    5867
    5968procedure TCore.DataModuleDestroy(Sender: TObject);
    6069begin
     70  FreeAndNil(StoredDimension);
    6171  FreeAndNil(AcronymDb);
    6272end;
     
    116126      FormMain.ProjectOpen(FileNameOption);
    117127    end;
     128    ScaleDPI;
    118129    FormMain.UpdateAcronymsList;
    119130    FormMain.ListViewFilter1.UpdateFromListView(FormMain.ListViewAcronyms);
     
    125136begin
    126137  FormMain.LoadConfig;
     138
     139  with TRegistryEx.Create do
     140  try
     141    RootKey := HKEY_CURRENT_USER;
     142    OpenKey(DefaultRegKey, True);
     143    ScaleDPI1.DPI := Point(ReadIntegerWithDefault('DPIX', 96), ReadIntegerWithDefault('DPIY', 96));
     144    ScaleDPI1.AutoDetect := ReadBoolWithDefault('DPIAuto', True);
     145  finally
     146    Free;
     147  end;
    127148end;
    128149
     
    130151begin
    131152  FormMain.SaveConfig;
     153
     154  with TRegistryEx.Create do
     155  try
     156    RootKey := HKEY_CURRENT_USER;
     157    OpenKey(DefaultRegKey, True);
     158    WriteInteger('DPIX', ScaleDPI1.DPI.X);
     159    WriteInteger('DPIY', ScaleDPI1.DPI.Y);
     160    WriteBool('DPIAuto', ScaleDPI1.AutoDetect);
     161  finally
     162    Free;
     163  end;
     164end;
     165
     166procedure TCore.ScaleDPI;
     167var
     168  I: Integer;
     169begin
     170  //ScaleDPI1.DPI := Point(150, 150);
     171  with ScaleDPI1 do
     172  if (DesignDPI.X <> DPI.X) or (DesignDPI.Y <> DPI.Y) then begin
     173    for I := 0 to Screen.FormCount - 1 do begin
     174      //StoreDimensions(Screen.Forms[I], StoredDimension);
     175      //ScaleDimensions(Screen.Forms[I], StoredDimension);
     176    end;
     177  end;
    132178end;
    133179
Note: See TracChangeset for help on using the changeset viewer.