From a152f6fb8f45800b10a3b1f619959a02788b8d02 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 21 Mar 2012 02:51:15 +0000 Subject: [PATCH] win32: return normal size for minimized windows in GetWindowSize() - fixes issue #0021508 git-svn-id: trunk@36184 - --- lcl/interfaces/win32/win32winapi.inc | 42 +++++++++++++--------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/lcl/interfaces/win32/win32winapi.inc b/lcl/interfaces/win32/win32winapi.inc index a03c4e2962..cb55b6e3d9 100644 --- a/lcl/interfaces/win32/win32winapi.inc +++ b/lcl/interfaces/win32/win32winapi.inc @@ -2286,21 +2286,22 @@ var Dec(Height, Windows.GetSystemMetrics(SM_CYCAPTION)); end; -begin + procedure SetWidthHeightFromRect(const R: TRect); inline; + begin + with R do + begin + Width := Right - Left; + Height := Bottom - Top; + end; + end; +begin WP.length := SizeOf(WP); Result := Boolean(Windows.GetWindowPlacement(Handle, WP)); if not Result then Exit; - if (WP.showCmd = SW_MINIMIZE) or (WP.showCmd = SW_SHOWMINIMIZED) then - begin - Width := 0; - Height := 0; - Exit; - end; - // if it is a top level window then you can't use the normal size: // maximized or aero snap windows will have problems if (GetWindowLong(Handle, GWL_STYLE) and WS_CHILD = 0) then @@ -2310,30 +2311,27 @@ begin Result := GetWindowInfo(Handle, @Info); if Result then begin - with Info.rcWindow do - begin - Width := Right - Left; - Height := Bottom - Top; - end; + // for minimized window use normal position, in other case use rcWindow of WindowInfo + if (WP.showCmd = SW_MINIMIZE) or (WP.showCmd = SW_SHOWMINIMIZED) then + SetWidthHeightFromRect(WP.rcNormalPosition) + else + SetWidthHeightFromRect(Info.rcWindow); Width := Width - 2 * Integer(Info.cxWindowBorders); Height := Height - 2 * Integer(Info.cyWindowBorders); ExcludeCaption; //WriteLn('W = ', Width, ' H = ', Height); Exit; end; - Result := Boolean(Windows.GetWindowRect(Handle, @R)); - with R do + if (WP.showCmd = SW_MINIMIZE) or (WP.showCmd = SW_SHOWMINIMIZED) then + SetWidthHeightFromRect(WP.rcNormalPosition) + else begin - Width := Right - Left; - Height := Bottom - Top; + Result := Boolean(Windows.GetWindowRect(Handle, @R)); + SetWidthHeightFromRect(R); end; end else - with WP.rcNormalPosition do - begin - Width := Right - Left; - Height := Bottom - Top; - end; + SetWidthHeightFromRect(WP.rcNormalPosition); WindowInfo := GetWin32WindowInfo(Handle);