win32: return normal size for minimized windows in GetWindowSize() - fixes issue #0021508

git-svn-id: trunk@36184 -
This commit is contained in:
paul 2012-03-21 02:51:15 +00:00
parent 5a475a393d
commit a152f6fb8f

View File

@ -2286,21 +2286,22 @@ var
Dec(Height, Windows.GetSystemMetrics(SM_CYCAPTION)); Dec(Height, Windows.GetSystemMetrics(SM_CYCAPTION));
end; 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); WP.length := SizeOf(WP);
Result := Boolean(Windows.GetWindowPlacement(Handle, WP)); Result := Boolean(Windows.GetWindowPlacement(Handle, WP));
if not Result then if not Result then
Exit; 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: // if it is a top level window then you can't use the normal size:
// maximized or aero snap windows will have problems // maximized or aero snap windows will have problems
if (GetWindowLong(Handle, GWL_STYLE) and WS_CHILD = 0) then if (GetWindowLong(Handle, GWL_STYLE) and WS_CHILD = 0) then
@ -2310,30 +2311,27 @@ begin
Result := GetWindowInfo(Handle, @Info); Result := GetWindowInfo(Handle, @Info);
if Result then if Result then
begin begin
with Info.rcWindow do // for minimized window use normal position, in other case use rcWindow of WindowInfo
begin if (WP.showCmd = SW_MINIMIZE) or (WP.showCmd = SW_SHOWMINIMIZED) then
Width := Right - Left; SetWidthHeightFromRect(WP.rcNormalPosition)
Height := Bottom - Top; else
end; SetWidthHeightFromRect(Info.rcWindow);
Width := Width - 2 * Integer(Info.cxWindowBorders); Width := Width - 2 * Integer(Info.cxWindowBorders);
Height := Height - 2 * Integer(Info.cyWindowBorders); Height := Height - 2 * Integer(Info.cyWindowBorders);
ExcludeCaption; ExcludeCaption;
//WriteLn('W = ', Width, ' H = ', Height); //WriteLn('W = ', Width, ' H = ', Height);
Exit; Exit;
end; end;
Result := Boolean(Windows.GetWindowRect(Handle, @R)); if (WP.showCmd = SW_MINIMIZE) or (WP.showCmd = SW_SHOWMINIMIZED) then
with R do SetWidthHeightFromRect(WP.rcNormalPosition)
else
begin begin
Width := Right - Left; Result := Boolean(Windows.GetWindowRect(Handle, @R));
Height := Bottom - Top; SetWidthHeightFromRect(R);
end; end;
end end
else else
with WP.rcNormalPosition do SetWidthHeightFromRect(WP.rcNormalPosition);
begin
Width := Right - Left;
Height := Bottom - Top;
end;
WindowInfo := GetWin32WindowInfo(Handle); WindowInfo := GetWin32WindowInfo(Handle);