]> git.saurik.com Git - wxWidgets.git/commitdiff
Work around wrong client size computation for not yet shown maximized windows.
authorVadim Zeitlin <vadim@wxwidgets.org>
Fri, 23 Apr 2010 19:34:36 +0000 (19:34 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Fri, 23 Apr 2010 19:34:36 +0000 (19:34 +0000)
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

src/msw/toplevel.cpp
src/msw/window.cpp

index dc5b8bd83d797b22d9d4e426f6a23655c2b1bd7b..88cc5dc6836fb9feea90ccd78b9e765204a36a4a 100644 (file)
@@ -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;
 }
 
index b814cb65659f77b0f44253d5db8169409dd40968..3b8ced6092b507aeb3d972a0442fad42a3e101ad 100644 (file)
@@ -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;