From 65e40fa6a8c2e05a1a5fa898d4a201f01ccff42b Mon Sep 17 00:00:00 2001 From: ondrej Date: Thu, 24 Mar 2016 13:37:23 +0000 Subject: [PATCH] lcl: fix position for poMainFormCenter. Issue #29887 git-svn-id: trunk@52043 - --- lcl/include/customform.inc | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/lcl/include/customform.inc b/lcl/include/customform.inc index c836589825..2f56c02414 100644 --- a/lcl/include/customform.inc +++ b/lcl/include/customform.inc @@ -1270,7 +1270,8 @@ var X, Y: integer; p: TPosition; AForm: TCustomForm; - RealRect: TRect; + RealRect, AFormRealRect: TRect; + AFormRealWidth, AFormRealHeight: Integer; begin if (Parent <> nil) or (ParentWindow <> 0) then exit; @@ -1323,8 +1324,17 @@ begin Y := (AForm.ClientHeight - RealHeight) div 2; end else begin - X := ((AForm.Width - RealWidth) div 2) + AForm.Left; - Y := ((AForm.Height - RealHeight) div 2) + AForm.Top; + if AForm.HandleAllocated and (GetWindowRect(AForm.Handle, AFormRealRect) <> 0) then + begin // success + AFormRealWidth := AFormRealRect.Right-AFormRealRect.Left; + AFormRealHeight := AFormRealRect.Bottom-AFormRealRect.Top; + end else + begin // error + AFormRealWidth := AForm.Width; + AFormRealHeight := AForm.Height; + end; + X := ((AFormRealWidth - RealWidth) div 2) + AForm.Left; + Y := ((AFormRealHeight - RealHeight) div 2) + AForm.Top; end; end; end;