From: Vadim Zeitlin Date: Fri, 23 Apr 2010 19:34:36 +0000 (+0000) Subject: Work around wrong client size computation for not yet shown maximized windows. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/e259ce57e63d56b387136fb18ef8d2e397024198 Work around wrong client size computation for not yet shown maximized windows. The client size of maximized windows which hadn't been shown yet isn't computed correctly by wxMSW because WM_NCCALCSIZE returns too small values for some reason. Attempts to fix this were unsuccessful so just ensure that the window is re-laid out using the right size from WM_SIZE it receives when it is shown instead of using the wrong pending size. Closes #11762. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64115 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/msw/toplevel.cpp b/src/msw/toplevel.cpp index dc5b8bd83d..88cc5dc683 100644 --- a/src/msw/toplevel.cpp +++ b/src/msw/toplevel.cpp @@ -662,6 +662,16 @@ bool wxTopLevelWindowMSW::Show(bool show) nShowCmd = SW_HIDE; } + // we only set pending size if we're maximized before being shown, now that + // we're shown we don't need it any more (it is reset in size event handler + // for child windows but we have to do it ourselves for this parent window) + // + // make sure to reset it before actually showing the window as this will + // generate WM_SIZE events and we want to use the correct client size from + // them, not the size returned by WM_NCCALCSIZE in DoGetClientSize() which + // turns out to be wrong for maximized windows (see #11762) + m_pendingSize = wxDefaultSize; + DoShowWindow(nShowCmd); #if defined(__WXWINCE__) && (_WIN32_WCE >= 400 && !defined(__POCKETPC__) && !defined(__SMARTPHONE__)) @@ -671,11 +681,6 @@ bool wxTopLevelWindowMSW::Show(bool show) frame->GetMenuBar()->AddAdornments(GetWindowStyleFlag()); #endif - // we only set pending size if we're maximized before being shown, now that - // we're shown we don't need it any more (it is reset in size event handler - // for child windows but we have to do it ourselves for this parent window) - m_pendingSize = wxDefaultSize; - return true; } diff --git a/src/msw/window.cpp b/src/msw/window.cpp index b814cb6565..3b8ced6092 100644 --- a/src/msw/window.cpp +++ b/src/msw/window.cpp @@ -1819,6 +1819,18 @@ void wxWindowMSW::DoGetClientSize(int *x, int *y) const if ( m_pendingSize != wxDefaultSize ) { // we need to calculate the client size corresponding to pending size + // + // FIXME: Unfortunately this doesn't work correctly for the maximized + // top level windows, the returned values are too small (e.g. + // under Windows 7 on a 1600*1200 screen with task bar on the + // right the pending size for a maximized window is 1538*1200 + // and WM_NCCALCSIZE returns 1528*1172 even though the correct + // client size of such window is 1538*1182). No idea how to fix + // it though, setting WS_MAXIMIZE in GWL_STYLE before calling + // WM_NCCALCSIZE doesn't help and AdjustWindowRectEx() doesn't + // work in this direction neither. So we just have to live with + // the slightly wrong results and relayout the window when it + // gets finally shown in its maximized state (see #11762). RECT rect; rect.left = m_pendingPosition.x; rect.top = m_pendingPosition.y;