mirror of
https://git.vladimir.cc/vladimir/ewsdr.git
synced 2026-08-26 21:57:32 +00:00
Fix window geometry scaling and close deadlock
This commit is contained in:
+54
-7
@@ -492,6 +492,7 @@ type
|
||||
procedure RestoreBand(BandIdx: Integer);
|
||||
procedure SaveAllAndExit;
|
||||
procedure RestoreWindowBounds;
|
||||
procedure SaveWindowBounds;
|
||||
function MakeGlobalSettings: TGlobalSettings;
|
||||
function MakeBandSettings: TBandSettings;
|
||||
procedure FreqDispBChanged(Sender: TObject; NewFreq: Int64);
|
||||
@@ -924,18 +925,64 @@ end;
|
||||
|
||||
procedure TMainForm.RestoreWindowBounds;
|
||||
var
|
||||
L, T, Wd, Ht: Integer;
|
||||
L, T, Wd, Ht, SavedDPI, CurDPI: Integer;
|
||||
R, WA: TRect;
|
||||
Mon: TMonitor;
|
||||
begin
|
||||
FSettings.LoadWindowBounds(L, T, Wd, Ht);
|
||||
FSettings.LoadWindowBounds(L, T, Wd, Ht, SavedDPI);
|
||||
if (Wd > 400) and (Ht > 300) then
|
||||
begin
|
||||
Left := L;
|
||||
Top := T;
|
||||
Width := Wd;
|
||||
Height := Ht;
|
||||
CurDPI := PixelsPerInch;
|
||||
if CurDPI <= 0 then CurDPI := Screen.PixelsPerInch;
|
||||
if CurDPI <= 0 then CurDPI := 96;
|
||||
if SavedDPI <= 0 then SavedDPI := CurDPI;
|
||||
|
||||
if SavedDPI <> CurDPI then
|
||||
begin
|
||||
L := MulDiv(L, CurDPI, SavedDPI);
|
||||
T := MulDiv(T, CurDPI, SavedDPI);
|
||||
Wd := MulDiv(Wd, CurDPI, SavedDPI);
|
||||
Ht := MulDiv(Ht, CurDPI, SavedDPI);
|
||||
end;
|
||||
|
||||
Wd := Max(MulDiv(900, CurDPI, 96), Wd);
|
||||
Ht := Max(MulDiv(560, CurDPI, 96), Ht);
|
||||
R := Bounds(L, T, Wd, Ht);
|
||||
Mon := Screen.MonitorFromRect(R);
|
||||
if Mon <> nil then WA := Mon.WorkareaRect
|
||||
else WA := Screen.PrimaryMonitor.WorkareaRect;
|
||||
|
||||
if Wd > WA.Right - WA.Left then Wd := WA.Right - WA.Left;
|
||||
if Ht > WA.Bottom - WA.Top then Ht := WA.Bottom - WA.Top;
|
||||
L := EnsureRange(L, WA.Left, Max(WA.Left, WA.Right - Wd));
|
||||
T := EnsureRange(T, WA.Top, Max(WA.Top, WA.Bottom - Ht));
|
||||
|
||||
Position := poDesigned;
|
||||
SetBounds(L, T, Wd, Ht);
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TMainForm.SaveWindowBounds;
|
||||
var
|
||||
L, T, Wd, Ht, DPI: Integer;
|
||||
begin
|
||||
if WindowState = wsNormal then
|
||||
begin
|
||||
L := Left; T := Top; Wd := Width; Ht := Height;
|
||||
end
|
||||
else
|
||||
begin
|
||||
L := RestoredLeft; T := RestoredTop;
|
||||
Wd := RestoredWidth; Ht := RestoredHeight;
|
||||
end;
|
||||
|
||||
if (Wd <= 400) or (Ht <= 300) then Exit;
|
||||
DPI := PixelsPerInch;
|
||||
if DPI <= 0 then DPI := Screen.PixelsPerInch;
|
||||
if DPI <= 0 then DPI := 96;
|
||||
FSettings.SaveWindowBounds(L, T, Wd, Ht, DPI);
|
||||
end;
|
||||
|
||||
function TMainForm.MakeBandSettings: TBandSettings;
|
||||
begin
|
||||
Result.VfoA := FVfoA;
|
||||
@@ -1447,7 +1494,7 @@ begin
|
||||
end;
|
||||
// Размер окна сохраняем всегда (не зависит от подключения)
|
||||
FSettings.SaveStartupPreview(FVfoA, FVfoB, FSampleRate);
|
||||
FSettings.SaveWindowBounds(Left, Top, Width, Height);
|
||||
SaveWindowBounds;
|
||||
FSettings.Save;
|
||||
FSettings.Free;
|
||||
FWebServer.Stop;
|
||||
|
||||
Reference in New Issue
Block a user