From a6df5e7e1dd039d53c0be3f98af9088c99ea7203 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 28 May 2008 21:32:50 +0200 Subject: [PATCH] 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(+) diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 33f88317366..e60ab13df45 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 71f6b5567ed..1824a52b346 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 */ -- 2.11.4.GIT