user32: Although Windows sends WM_GETMINMAXINFO at the window creation time, it doesn't use returned values to set window size

Dmitry Timoshkov dmitry at codeweavers.com
Sat Jan 27 06:50:09 CST 2007


Hello,

this patch fixes the bug #3211. The test passes under XP and Win98 SE.

Changelog:
    user32: Although Windows sends WM_GETMINMAXINFO at the window creation
    time, it doesn't use returned values to set window size.

---
 dlls/user32/tests/win.c   |   45 +++++++++++++++++++++++++++++++++++++++++++++
 dlls/winex11.drv/window.c |   11 +++--------
 2 files changed, 48 insertions(+), 8 deletions(-)

diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 951c6aa..735c8aa 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -3712,6 +3712,8 @@ static void test_CreateWindow(void)
 {
     HWND hwnd, parent;
     HMENU hmenu;
+    RECT rc, rc_minmax;
+    MINMAXINFO minmax;
 
 #define expect_menu(window, menu) \
     SetLastError(0xdeadbeef); \
@@ -3904,6 +3906,49 @@ static void test_CreateWindow(void)
     ok(!IsMenu(hmenu), "IsMenu should fail\n");
     ok(GetLastError() == ERROR_INVALID_MENU_HANDLE, "IsMenu set error %d\n", GetLastError());
 
+    /* test child window sizing */
+    SetLastError(0xdeadbeef);
+    parent = CreateWindowEx(0, "static", NULL, WS_CAPTION | WS_SYSMENU | WS_THICKFRAME,
+                           0, 0, 100, 100, 0, 0, 0, NULL);
+    ok(parent != 0, "CreateWindowEx error %d\n", GetLastError());
+    expect_menu(parent, 0);
+    expect_style(parent, WS_CAPTION | WS_SYSMENU | WS_THICKFRAME | WS_CLIPSIBLINGS);
+    expect_ex_style(parent, WS_EX_WINDOWEDGE);
+
+    memset(&minmax, 0, sizeof(minmax));
+    SendMessage(parent, WM_GETMINMAXINFO, 0, (LPARAM)&minmax);
+    SetRect(&rc_minmax, 0, 0, minmax.ptMaxSize.x, minmax.ptMaxSize.y);
+    ok(IsRectEmpty(&rc_minmax), "rc_minmax is not empty\n");
+
+    GetClientRect(parent, &rc);
+    ok(rc_minmax.left >= rc.left && rc_minmax.top >= rc.top &&
+       rc_minmax.right <= rc.right && rc_minmax.bottom <= rc.bottom,
+       "rc_minmax (%d,%d-%d,%d) is not within of parent client rect (%d,%d-%d,%d)\n",
+       rc_minmax.left, rc_minmax.top, rc_minmax.right, rc_minmax.bottom,
+       rc.left, rc.top, rc.right, rc.bottom);
+    InflateRect(&rc, 200, 200);
+    trace("creating child with rect (%d,%d-%d,%d)\n", rc.left, rc.top, rc.right, rc.bottom);
+
+    SetLastError(0xdeadbeef);
+    hwnd = CreateWindowEx(0, "static", NULL, WS_CHILD | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME,
+                          rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top,
+                          parent, (HMENU)1, 0, NULL);
+    ok(hwnd != 0, "CreateWindowEx error %d\n", GetLastError());
+    expect_menu(hwnd, 1);
+    expect_style(hwnd, WS_CHILD | WS_CAPTION | WS_SYSMENU | WS_THICKFRAME);
+    expect_ex_style(hwnd, WS_EX_WINDOWEDGE);
+
+    OffsetRect(&rc, -rc.left, -rc.top);
+
+    GetWindowRect(hwnd, &rc_minmax);
+    OffsetRect(&rc_minmax, -rc_minmax.left, -rc_minmax.top);
+    ok(EqualRect(&rc, &rc_minmax), "rects don't match: (%d,%d-%d,%d) and (%d,%d-%d,%d)\n",
+       rc.left, rc.top, rc.right, rc.bottom,
+       rc_minmax.left, rc_minmax.top, rc_minmax.right, rc_minmax.bottom);
+
+    DestroyWindow(hwnd);
+    DestroyWindow(parent);
+
 #undef expect_menu
 #undef expect_style
 #undef expect_ex_style
diff --git a/dlls/winex11.drv/window.c b/dlls/winex11.drv/window.c
index e9fc4f0..3f67069 100644
--- a/dlls/winex11.drv/window.c
+++ b/dlls/winex11.drv/window.c
@@ -1075,15 +1075,10 @@ BOOL X11DRV_CreateWindow( HWND hwnd, CREATESTRUCTA *cs, BOOL unicode )
     if ((cs->style & WS_THICKFRAME) || !(cs->style & (WS_POPUP | WS_CHILD)))
     {
         POINT maxSize, maxPos, minTrack, maxTrack;
-
+        /* Although Windows sends WM_GETMINMAXINFO at the window creation time,
+         * it doesn't use returned values to set window size.
+         */
         WINPOS_GetMinMaxInfo( hwnd, &maxSize, &maxPos, &minTrack, &maxTrack);
-        if (maxSize.x < cs->cx) cs->cx = maxSize.x;
-        if (maxSize.y < cs->cy) cs->cy = maxSize.y;
-        if (cs->cx < 0) cs->cx = 0;
-        if (cs->cy < 0) cs->cy = 0;
-
-        SetRect( &rect, cs->x, cs->y, cs->x + cs->cx, cs->y + cs->cy );
-        if (!X11DRV_SetWindowPos( hwnd, 0, &rect, &rect, SWP_NOZORDER, NULL )) return FALSE;
     }
 
     /* send WM_NCCREATE */
-- 
1.4.4.4






More information about the wine-patches mailing list