Alexandre Julliard : user32: Check for wraparound in the initial window coordinates.

Alexandre Julliard julliard at winehq.org
Wed May 28 14:46:08 CDT 2008


Module: wine
Branch: master
Commit: a6df5e7e1dd039d53c0be3f98af9088c99ea7203
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=a6df5e7e1dd039d53c0be3f98af9088c99ea7203

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Wed May 28 21:32:50 2008 +0200

user32: Check for wraparound in the initial window coordinates.

---

 dlls/user32/tests/win.c |   25 +++++++++++++++++++++++++
 dlls/user32/win.c       |    3 +++
 2 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 33f8831..e60ab13 100644
--- a/dlls/user32/tests/win.c
+++ b/dlls/user32/tests/win.c
@@ -4230,6 +4230,31 @@ static void test_CreateWindow(void)
     ok( rc.bottom == 0, "invalid rect bottom %u\n", rc.bottom );
     DestroyWindow(hwnd);
 
+    /* we need a parent at 0,0 so that child coordinates match */
+    DestroyWindow(parent);
+    parent = CreateWindowEx(0, "MinMax_WndClass", NULL, WS_POPUP, 0, 0, 100, 100, 0, 0, 0, NULL);
+    ok(parent != 0, "CreateWindowEx error %d\n", GetLastError());
+
+    expected_cx = 100;
+    expected_cy = 0x7fffffff;
+    SetRect( &expected_rect, 10, 10, 110, 0x7fffffff );
+    hwnd = CreateWindowExA(0, "Sizes_WndClass", NULL, WS_CHILD, 10, 10, 100, 0x7fffffff, parent, 0, 0, NULL);
+    ok( hwnd != 0, "creation failed err %u\n", GetLastError());
+    GetClientRect( hwnd, &rc );
+    ok( rc.right == 100, "invalid rect right %u\n", rc.right );
+    ok( rc.bottom == 0x7fffffff - 10, "invalid rect bottom %u\n", rc.bottom );
+    DestroyWindow(hwnd);
+
+    expected_cx = 0x7fffffff;
+    expected_cy = 0x7fffffff;
+    SetRect( &expected_rect, 20, 10, 0x7fffffff, 0x7fffffff );
+    hwnd = CreateWindowExA(0, "Sizes_WndClass", NULL, WS_CHILD, 20, 10, 0x7fffffff, 0x7fffffff, parent, 0, 0, NULL);
+    ok( hwnd != 0, "creation failed err %u\n", GetLastError());
+    GetClientRect( hwnd, &rc );
+    ok( rc.right == 0x7fffffff - 20, "invalid rect right %u\n", rc.right );
+    ok( rc.bottom == 0x7fffffff - 10, "invalid rect bottom %u\n", rc.bottom );
+    DestroyWindow(hwnd);
+
     /* top level window */
     expected_cx = expected_cy = 200000;
     SetRect( &expected_rect, 0, 0, GetSystemMetrics(SM_CXMAXTRACK), GetSystemMetrics(SM_CYMAXTRACK) );
diff --git a/dlls/user32/win.c b/dlls/user32/win.c
index 71f6b55..1824a52 100644
--- a/dlls/user32/win.c
+++ b/dlls/user32/win.c
@@ -1119,6 +1119,9 @@ static HWND WIN_CreateWindowEx( CREATESTRUCTA *cs, LPCWSTR className, UINT flags
     if (cx < 0) cx = 0;
     if (cy < 0) cy = 0;
     SetRect( &rect, cs->x, cs->y, cs->x + cx, cs->y + cy );
+    /* check for wraparound */
+    if (cs->x + cx < cs->x) rect.right = 0x7fffffff;
+    if (cs->y + cy < cs->y) rect.bottom = 0x7fffffff;
     if (!set_window_pos( hwnd, 0, SWP_NOZORDER | SWP_NOACTIVATE, &rect, &rect, NULL )) goto failed;
 
     /* send WM_NCCREATE */




More information about the wine-cvs mailing list