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