Fixes for default WM_GETMINMAXINFO values

Dmitry Timoshkov dmitry at baikal.ru
Tue May 4 04:56:35 CDT 2004


Hello,

this patch fixes default window extents passed in MINMAXINFO structure
to a window. Now some picky applications are able to correctly size their
child windows.

Changelog:
    Dmitry Timoshkov <dmitry at codeweavers.com>
    - Maximized windows have no thick frame, it's changed to a border.
    - Take into account WS_CAPTION style when calculating default values.
    - MDI child windows receive slightly adjusted values for a maximized
      state.

diff -u cvs/hq/wine/dlls/user/tests/win.c wine/dlls/user/tests/win.c
--- cvs/hq/wine/dlls/user/tests/win.c	2004-05-04 14:33:56.000000000 +0900
+++ wine/dlls/user/tests/win.c	2004-05-04 18:47:27.000000000 +0900
@@ -913,6 +913,42 @@ static void test_MDI_create(HWND parent,
                                 (LPVOID)mdi_lParam_test_message);
     ok(mdi_child != 0, "MDI child creation failed\n");
     DestroyWindow(mdi_child);
+
+    /* maximized child */
+    mdi_child = CreateWindowExA(0, "MDI_child_Class_2", "MDI child",
+                                WS_CHILD | WS_MAXIMIZE,
+                                CW_USEDEFAULT, CW_USEDEFAULT,
+                                CW_USEDEFAULT, CW_USEDEFAULT,
+                                mdi_client, 0, GetModuleHandle(0),
+                                (LPVOID)mdi_lParam_test_message);
+    ok(mdi_child != 0, "MDI child creation failed\n");
+    DestroyWindow(mdi_child);
+}
+
+/**********************************************************************
+ * MDI_ChildGetMinMaxInfo (copied from windows/mdi.c)
+ *
+ * Note: The rule here is that client rect of the maximized MDI child
+ *	 is equal to the client rect of the MDI client window.
+ */
+static void MDI_ChildGetMinMaxInfo( HWND client, HWND hwnd, MINMAXINFO* lpMinMax )
+{
+    RECT rect;
+
+    GetClientRect( client, &rect );
+    AdjustWindowRectEx( &rect, GetWindowLongW( hwnd, GWL_STYLE ),
+                        0, GetWindowLongW( hwnd, GWL_EXSTYLE ));
+
+    rect.right -= rect.left;
+    rect.bottom -= rect.top;
+    lpMinMax->ptMaxSize.x = rect.right;
+    lpMinMax->ptMaxSize.y = rect.bottom;
+
+    lpMinMax->ptMaxPosition.x = rect.left;
+    lpMinMax->ptMaxPosition.y = rect.top;
+
+    trace("max rect (%ld,%ld - %ld, %ld)\n",
+           rect.left, rect.top, rect.right, rect.bottom);
 }
 
 static LRESULT WINAPI mdi_child_wnd_proc_1(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
@@ -969,6 +1005,66 @@ static LRESULT WINAPI mdi_child_wnd_proc
             }
             break;
         }
+
+        case WM_GETMINMAXINFO:
+        {
+            HWND client = GetParent(hwnd);
+            RECT rc;
+            MINMAXINFO *minmax = (MINMAXINFO *)lparam;
+            MINMAXINFO my_minmax;
+
+            GetWindowRect(client, &rc);
+            trace("MDI client %p window size = (%ld x %ld)\n", client, rc.right-rc.left, rc.bottom-rc.top);
+            GetClientRect(client, &rc);
+            trace("MDI client %p client size = (%ld x %ld)\n", client, rc.right, rc.bottom);
+            trace("screen size: %d x %d\n", GetSystemMetrics(SM_CXSCREEN),
+                                            GetSystemMetrics(SM_CYSCREEN));
+
+            GetWindowRect(client, &rc);
+            AdjustWindowRectEx(&rc, GetWindowLongA(hwnd, GWL_STYLE) & ~WS_CAPTION,
+                               0, GetWindowLongA(hwnd, GWL_EXSTYLE));
+            if (GetWindowLongA(hwnd, GWL_STYLE) & WS_THICKFRAME)
+                InflateRect(&rc, GetSystemMetrics(SM_CXBORDER), GetSystemMetrics(SM_CYBORDER));
+            trace("MDI child: calculated max window size = (%ld x %ld)\n", rc.right-rc.left, rc.bottom-rc.top);
+
+            trace("ptReserved = (%ld,%ld)\n"
+                  "ptMaxSize = (%ld,%ld)\n"
+                  "ptMaxPosition = (%ld,%ld)\n"
+                  "ptMinTrackSize = (%ld,%ld)\n"
+                  "ptMaxTrackSize = (%ld,%ld)\n",
+                  minmax->ptReserved.x, minmax->ptReserved.y,
+                  minmax->ptMaxSize.x, minmax->ptMaxSize.y,
+                  minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
+                  minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
+                  minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
+
+            ok(minmax->ptMaxSize.x == rc.right - rc.left, "default width of maximized child %ld != %ld\n",
+               minmax->ptMaxSize.x, rc.right - rc.left);
+            ok(minmax->ptMaxSize.y == rc.bottom - rc.top, "default height of maximized child %ld != %ld\n",
+               minmax->ptMaxSize.y, rc.bottom - rc.top);
+
+            DefMDIChildProcA(hwnd, msg, wparam, lparam);
+
+            trace("DefMDIChildProc returned:\n"
+                  "ptReserved = (%ld,%ld)\n"
+                  "ptMaxSize = (%ld,%ld)\n"
+                  "ptMaxPosition = (%ld,%ld)\n"
+                  "ptMinTrackSize = (%ld,%ld)\n"
+                  "ptMaxTrackSize = (%ld,%ld)\n",
+                  minmax->ptReserved.x, minmax->ptReserved.y,
+                  minmax->ptMaxSize.x, minmax->ptMaxSize.y,
+                  minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
+                  minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
+                  minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
+
+            MDI_ChildGetMinMaxInfo(client, hwnd, &my_minmax);
+            ok(minmax->ptMaxSize.x == my_minmax.ptMaxSize.x, "default width of maximized child %ld != %ld\n",
+               minmax->ptMaxSize.x, my_minmax.ptMaxSize.x);
+            ok(minmax->ptMaxSize.y == my_minmax.ptMaxSize.y, "default height of maximized child %ld != %ld\n",
+               minmax->ptMaxSize.y, my_minmax.ptMaxSize.y);
+
+            return 1;
+        }
     }
     return DefMDIChildProcA(hwnd, msg, wparam, lparam);
 }
@@ -999,6 +1095,33 @@ static LRESULT WINAPI mdi_child_wnd_proc
             ok(cs->cy == 0, "%d != 0\n", cs->cy);
             break;
         }
+
+        case WM_GETMINMAXINFO:
+        {
+            HWND parent = GetParent(hwnd);
+            RECT rc;
+            MINMAXINFO *minmax = (MINMAXINFO *)lparam;
+
+            GetClientRect(parent, &rc);
+            trace("parent %p client size = (%ld x %ld)\n", parent, rc.right, rc.bottom);
+
+            trace("ptReserved = (%ld,%ld)\n"
+                  "ptMaxSize = (%ld,%ld)\n"
+                  "ptMaxPosition = (%ld,%ld)\n"
+                  "ptMinTrackSize = (%ld,%ld)\n"
+                  "ptMaxTrackSize = (%ld,%ld)\n",
+                  minmax->ptReserved.x, minmax->ptReserved.y,
+                  minmax->ptMaxSize.x, minmax->ptMaxSize.y,
+                  minmax->ptMaxPosition.x, minmax->ptMaxPosition.y,
+                  minmax->ptMinTrackSize.x, minmax->ptMinTrackSize.y,
+                  minmax->ptMaxTrackSize.x, minmax->ptMaxTrackSize.y);
+
+            ok(minmax->ptMaxSize.x == rc.right, "default width of maximized child %ld != %ld\n",
+               minmax->ptMaxSize.x, rc.right);
+            ok(minmax->ptMaxSize.y == rc.bottom, "default height of maximized child %ld != %ld\n",
+               minmax->ptMaxSize.y, rc.bottom);
+            break;
+        }
     }
     return DefWindowProcA(hwnd, msg, wparam, lparam);
 }
diff -u cvs/hq/wine/windows/winpos.c wine/windows/winpos.c
--- cvs/hq/wine/windows/winpos.c	2003-11-29 18:32:19.000000000 +0800
+++ wine/windows/winpos.c	2004-05-04 18:47:27.000000000 +0900
@@ -753,9 +753,18 @@ void WINPOS_GetMinMaxInfo( HWND hwnd, PO
 
     if (style & WS_CHILD)
     {
-        GetClientRect(GetParent(hwnd), &rc);
-        MinMax.ptMaxSize.x = rc.right;
-        MinMax.ptMaxSize.y = rc.bottom;
+        if (exstyle & WS_EX_MDICHILD)
+        {
+            style &= ~WS_CAPTION;
+
+            GetWindowRect(GetParent(hwnd), &rc);
+            AdjustWindowRectEx(&rc, style, 0, exstyle);
+        }
+        else
+            GetClientRect(GetParent(hwnd), &rc);
+
+        MinMax.ptMaxSize.x = rc.right - rc.left;
+        MinMax.ptMaxSize.y = rc.bottom - rc.top;
     }
     else
     {
@@ -775,17 +784,17 @@ void WINPOS_GetMinMaxInfo( HWND hwnd, PO
     else
     {
         xinc = yinc = 0;
-        if (HAS_THICKFRAME(style))
-        {
-            xinc += GetSystemMetrics(SM_CXFRAME);
-            yinc += GetSystemMetrics(SM_CYFRAME);
-        }
-        if (style & WS_BORDER)
+        /* maximized windows change a frame to a border */
+        if (HAS_THICKFRAME(style) || (style & WS_BORDER))
         {
             xinc += GetSystemMetrics(SM_CXBORDER);
             yinc += GetSystemMetrics(SM_CYBORDER);
         }
     }
+
+    if ((style & WS_CAPTION) == WS_CAPTION)
+        yinc += GetSystemMetrics(SM_CYCAPTION);
+
     MinMax.ptMaxSize.x += 2 * xinc;
     MinMax.ptMaxSize.y += 2 * yinc;
 






More information about the wine-patches mailing list