Fix recent regression in wxMSW wxTopLevelWindow::IsMaximized()

Recent 3518f1a7d8 broke IsMaximized()
return value when the window was visible and had been previously
maximized by calling Maximize(), but wasn't actually maximized any
longer because it started to always return true when m_showCmd was set
to SW_MAXIMIZE.

Fix this by only using m_showCmd when the window is hidden, as it
shouldn't matter what it is when it's shown. Also simplify/optimize the
logic of IsMaximized() to use either ::IsZoomed() or m_showCmd depending
on whether the window is shown or not, but not both.

See https://github.com/wxWidgets/wxWidgets/pull/842

Closes #18163.
This commit is contained in:
Vadim Zeitlin 2018-07-06 18:58:00 +02:00
parent c93ccda035
commit 5766280311

View File

@ -648,9 +648,14 @@ void wxTopLevelWindowMSW::Maximize(bool maximize)
bool wxTopLevelWindowMSW::IsMaximized() const
{
return IsAlwaysMaximized() ||
(::IsZoomed(GetHwnd()) != 0) ||
m_showCmd == SW_MAXIMIZE;
if ( IsAlwaysMaximized() )
return true;
// If the window is shown, just ask Windows if it's maximized. But hidden
// windows are not really maximized, even after Maximize() is called on
// them, so for them we check if we're scheduled to maximize the window
// when it's shown instead.
return IsShown() ? ::IsZoomed(GetHwnd()) != 0 : m_showCmd == SW_MAXIMIZE;
}
void wxTopLevelWindowMSW::Iconize(bool iconize)