mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-23 00:59:31 +02:00
LCL: form: force scale bounds in WM_DPICHANGED message handler. Issue #32162
git-svn-id: trunk@55530 -
This commit is contained in:
parent
da5965d3fc
commit
3d5bee5c9c
@ -2257,14 +2257,33 @@ end;
|
||||
|
||||
procedure TCustomForm.WMDPIChanged(var Msg: TLMessage);
|
||||
var
|
||||
NewDpi: integer;
|
||||
NewDpi, I, L: integer;
|
||||
begin
|
||||
if Parent=nil then
|
||||
begin
|
||||
NewDpi := hi(Msg.wParam);
|
||||
if Application.Scaled and Scaled and (NewDpi<>PixelsPerInch) then
|
||||
AutoAdjustLayout(lapAutoAdjustForDPI, PixelsPerInch, NewDpi,
|
||||
Width, MulDiv(Width, NewDpi, PixelsPerInch));
|
||||
begin
|
||||
{ Problem (Windows): if the form is shown the first time on a secondary monitor
|
||||
with a different DPI settings, the WM_DPICHANGED message is sent within
|
||||
UpdateBounds when BoundsLockCount>0 which means the bounds are not scaled.
|
||||
We force to update the bounds. See issue 32162.
|
||||
(A better solution is welcome.)
|
||||
}
|
||||
I := -1;
|
||||
while BoundsLockCount>0 do
|
||||
begin
|
||||
EndUpdateBounds;
|
||||
Inc(I);
|
||||
end;
|
||||
try
|
||||
AutoAdjustLayout(lapAutoAdjustForDPI, PixelsPerInch, NewDpi,
|
||||
Width, MulDiv(Width, NewDpi, PixelsPerInch));
|
||||
finally
|
||||
for L := 0 to I do
|
||||
BeginUpdateBounds;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user