Issue #1482: fix width and height of session manager being reset to design-time values through an internal Resize event. Now set dimensions in OnCreate rather than in OnShow without DPI awareness. Also, respect a non-96 value of a form's DesignTimePPI + PixelsPerInch in AppSettings.WriteIntDpiAware.

This commit is contained in:
Ansgar Becker
2025-03-22 18:33:08 +01:00
parent 930d42afee
commit 8afe721e6f
2 changed files with 18 additions and 32 deletions

View File

@ -92,23 +92,8 @@ type
// Download
THttpDownload = class(TFPHttpClient)
//private
// FOwner: TComponent;
// FURL: String;
// FLastContent: String;
// FBytesRead: Integer;
// FContentLength: Integer;
// FTimeOut: Cardinal;
// FOnProgress: TNotifyEvent;
public
constructor Create(Owner: TComponent);
// procedure SendRequest(Filename: String);
// property OnProgress: TNotifyEvent read FOnProgress write FOnProgress;
// property URL: String read FURL write FURL;
// property TimeOut: Cardinal read FTimeOut write FTimeOut;
// property BytesRead: Integer read FBytesRead;
// property ContentLength: Integer read FContentLength;
// property LastContent: String read FLastContent;
end;
// Extended string list with support for empty values
@ -4231,7 +4216,7 @@ function TAppSettings.ReadIntDpiAware(Index: TAppSettingIndex; AControl: TContro
begin
// take a forms DesignTimePPI into account
Result := ReadInt(Index, FormatName, Default);
Result := AControl.Scale96ToForm(Result);
Result := AControl.ScaleDesignToForm(Result);
end;
@ -4317,7 +4302,7 @@ end;
procedure TAppSettings.WriteIntDpiAware(Index: TAppSettingIndex; AControl: TControl; Value: Integer; FormatName: String='');
begin
Value := AControl.ScaleFormTo96(Value);
Value := AControl.ScaleFormToDesign(Value);
WriteInt(Index, Value, FormatName);
end;

View File

@ -12,7 +12,7 @@ interface
uses
SysUtils, Classes, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, ComCtrls,
laz.VirtualTrees, Menus, Graphics, Generics.Collections, extra_controls,
dbconnection, RegExpr, Types, GraphUtil, StrUtils,
dbconnection, RegExpr, Types, GraphUtil, StrUtils, FileUtil,
Math, ActnList, StdActns, comboex, EditBtn, Buttons, colorbox;
type
@ -284,8 +284,20 @@ var
ComboItem: TComboExItem;
Placeholders: TStringList;
i: Integer;
ExeFiles: TStringDynArray;
ExeFiles: TStringList;
begin
Width := AppSettings.ReadInt(asSessionManagerWindowWidth);
Height := AppSettings.ReadInt(asSessionManagerWindowHeight);
Left := AppSettings.ReadInt(asSessionManagerWindowLeft, '', Left);
Top := AppSettings.ReadInt(asSessionManagerWindowTop, '', Top);
// Move to visible area if window was on a now plugged off monitor previously
MakeFullyVisible;
pnlLeft.Width := AppSettings.ReadInt(asSessionManagerListWidth);
splitterMain.OnMoved(Sender);
FixVT(ListSessions);
RestoreListSetup(ListSessions);
// Fix GUI stuff
HasSizeGrip := True;
Caption := GetWindowCaption;
@ -322,14 +334,14 @@ begin
editLogFilePath.Hint := FilenameHint;
// Populate dropdown with supported SSH executables
{ExeFiles := TDirectory.GetFiles(ExtractFilePath(ParamStr(0)), '*.exe');
ExeFiles := FindAllFiles(ExtractFilePath(ParamStr(0)), '*.exe', False);
for ExePath in ExeFiles do begin
ExeFile := ExtractFileName(ExePath);
if ExecRegExprI('([pk]link|putty)', ExeFile) then begin
comboSSHExe.Items.Add(ExeFile);
end;
end;
SetLength(ExeFiles, 0);}
ExeFiles.Free;
comboSSHExe.Items.Add('ssh.exe');
end;
@ -400,17 +412,6 @@ var
PSess: PConnectionParameters;
Node: PVirtualNode;
begin
Width := AppSettings.ReadIntDpiAware(asSessionManagerWindowWidth, Self);
Height := AppSettings.ReadIntDpiAware(asSessionManagerWindowHeight, Self);
Left := AppSettings.ReadInt(asSessionManagerWindowLeft, '', Left);
Top := AppSettings.ReadInt(asSessionManagerWindowTop, '', Top);
// Move to visible area if window was on a now plugged off monitor previously
MakeFullyVisible;
pnlLeft.Width := AppSettings.ReadIntDpiAware(asSessionManagerListWidth, Self);
splitterMain.OnMoved(Sender);
FixVT(ListSessions);
RestoreListSetup(ListSessions);
// Init sessions tree
RefreshSessions(nil);