lcl: fixed TCustomForm.GetMonitor to avoid calling SetBounds

This commit is contained in:
mattias 2022-05-17 10:32:34 +02:00
parent 819e17fc38
commit 174cf206d4

View File

@ -2358,7 +2358,7 @@ begin
end;
function TCustomForm.GetMonitor: TMonitor;
{$IFDEF EnableGetMonitor}
function GetDefaultMonitor: TMonitor;
var
aForm: TCustomForm;
@ -2383,7 +2383,7 @@ function TCustomForm.GetMonitor: TMonitor;
Result:=Screen.GetPrimaryMonitor;
end;
end;
{$ENDIF}
var
ParentForm: TCustomForm;
begin
@ -2401,7 +2401,6 @@ begin
if HandleAllocated then begin
if (not HandleObjectShouldBeVisible) then
begin
{$IFDEF EnableGetMonitor}
// hidden forms are not updated by DoSendBoundsToInterface
if (fsFirstShow in FormState) then
begin
@ -2429,12 +2428,6 @@ begin
TWSWinControlClass(WidgetSetClass).SetBounds(Self, Left, Top, Width, Height);
Result := Screen.MonitorFromWindow(Handle, mdNearest);
end;
{$ELSE}
// ensure widgetset has latest coordinates // invisible forms are not updated by DoSendBoundsToInterface
if (not HandleObjectShouldBeVisible) then
TWSWinControlClass(WidgetSetClass).SetBounds(Self, Left, Top, Width, Height);
Result := Screen.MonitorFromWindow(Handle, mdNearest);
{$ENDIF}
end else
Result := Screen.MonitorFromWindow(Handle, mdNearest);
end