From a7c6c82c2b01de2b8b21f6246878884f4bb08c96 Mon Sep 17 00:00:00 2001 From: zeljan1 Date: Tue, 1 Apr 2025 21:37:09 +0200 Subject: [PATCH] Qt5,Qt6: fixes sizepos loop error. issue #41508 --- lcl/interfaces/qt5/qtwinapi.inc | 8 +++++++- lcl/interfaces/qt6/qtwinapi.inc | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/lcl/interfaces/qt5/qtwinapi.inc b/lcl/interfaces/qt5/qtwinapi.inc index 2dcfcc2676..ce4ee881cc 100644 --- a/lcl/interfaces/qt5/qtwinapi.inc +++ b/lcl/interfaces/qt5/qtwinapi.inc @@ -4440,7 +4440,13 @@ begin {$endif} if Handle = 0 then Exit(False); - R := TQtWidget(Handle).getFrameGeometry; + if QWidget_isTopLevel(TQtWidget(Handle).Widget) then + begin + R := Rect(0, 0, 0, 0); + if GetWindowRect(Handle, R) = 0 then + R := TQtWidget(Handle).getFrameGeometry; + end else + R := TQtWidget(Handle).getFrameGeometry; Left := R.Left; Top := R.Top; Result := True; diff --git a/lcl/interfaces/qt6/qtwinapi.inc b/lcl/interfaces/qt6/qtwinapi.inc index adaa831b72..b98e55c80c 100644 --- a/lcl/interfaces/qt6/qtwinapi.inc +++ b/lcl/interfaces/qt6/qtwinapi.inc @@ -4467,7 +4467,13 @@ begin {$endif} if Handle = 0 then Exit(False); - R := TQtWidget(Handle).getFrameGeometry; + if QWidget_isTopLevel(TQtWidget(Handle).Widget) then + begin + R := Rect(0, 0, 0, 0); + if GetWindowRect(Handle, R) = 0 then + R := TQtWidget(Handle).getFrameGeometry; + end else + R := TQtWidget(Handle).getFrameGeometry; Left := R.Left; Top := R.Top; Result := True;