Issue #1503: reactivate DPI awareness, and try to read/write component dimensions DPI independently

This commit is contained in:
Ansgar Becker
2021-12-26 13:06:24 +01:00
parent 07f00ed88d
commit d46716ff2e
19 changed files with 153 additions and 125 deletions

View File

@ -237,10 +237,12 @@ type
constructor Create;
destructor Destroy; override;
function ReadInt(Index: TAppSettingIndex; FormatName: String=''; Default: Integer=0): Integer;
function ReadIntDpiAware(Index: TAppSettingIndex; AControl: TControl; FormatName: String=''; Default: Integer=0): Integer;
function ReadBool(Index: TAppSettingIndex; FormatName: String=''; Default: Boolean=False): Boolean;
function ReadString(Index: TAppSettingIndex; FormatName: String=''; Default: String=''): String; overload;
function ReadString(ValueName: String): String; overload;
procedure WriteInt(Index: TAppSettingIndex; Value: Integer; FormatName: String='');
procedure WriteIntDpiAware(Index: TAppSettingIndex; AControl: TControl; Value: Integer; FormatName: String='');
procedure WriteBool(Index: TAppSettingIndex; Value: Boolean; FormatName: String='');
procedure WriteString(Index: TAppSettingIndex; Value: String; FormatName: String=''); overload;
procedure WriteString(ValueName, Value: String); overload;
@ -3997,6 +3999,13 @@ begin
end;
function TAppSettings.ReadIntDpiAware(Index: TAppSettingIndex; AControl: TControl; FormatName: String=''; Default: Integer=0): Integer;
begin
Result := ReadInt(Index, FormatName, Default);
Result := Round(Result * AControl.ScaleFactor);
end;
function TAppSettings.ReadBool(Index: TAppSettingIndex; FormatName: String=''; Default: Boolean=False): Boolean;
var
I: Integer;
@ -4077,6 +4086,13 @@ begin
end;
procedure TAppSettings.WriteIntDpiAware(Index: TAppSettingIndex; AControl: TControl; Value: Integer; FormatName: String='');
begin
Value := Round(Value / AControl.ScaleFactor);
WriteInt(Index, Value, FormatName);
end;
procedure TAppSettings.WriteBool(Index: TAppSettingIndex; Value: Boolean; FormatName: String='');
begin
Write(Index, FormatName, adBool, 0, Value, '');