lcl: fixed TCustomForm.GetMonitor when handleallocated and visible

This commit is contained in:
mattias 2022-05-16 15:25:08 +02:00
parent 46e5442514
commit becdd42b6d

View File

@ -2387,6 +2387,7 @@ function TCustomForm.GetMonitor: TMonitor;
var var
ParentForm: TCustomForm; ParentForm: TCustomForm;
begin begin
Result:=nil;
if Assigned(Parent) then if Assigned(Parent) then
begin begin
ParentForm := GetParentForm(Self); ParentForm := GetParentForm(Self);
@ -2434,7 +2435,8 @@ 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);
{$ENDIF} {$ENDIF}
end; end else
Result := Screen.MonitorFromWindow(Handle, mdNearest);
end end
else else
Result := Screen.MonitorFromPoint(point(Left,Top)); Result := Screen.MonitorFromPoint(point(Left,Top));