From a2b7aafdaea0fde68cfdee6650eff44a28b3b5c9 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Thu, 2 Apr 2009 03:53:00 -0400 Subject: [PATCH] user32: Implemented GetWindowRgnBox with some tests. --- dlls/user32/tests/win.c | 45 +++++++++++++++++++++++++++++++++++++++++ dlls/user32/user32.spec | 2 +- dlls/user32/winpos.c | 20 ++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 89eefcda4b5..4aa36742d27 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -51,6 +51,7 @@ static BOOL (WINAPI *pGetLayeredWindowAttributes)(HWND,COLORREF*,BYTE*,DWORD*); static BOOL (WINAPI *pSetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD); static BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR,LPMONITORINFO); static HMONITOR (WINAPI *pMonitorFromPoint)(POINT,DWORD); +static int (WINAPI *pGetWindowRgnBox)(HWND,LPRECT); static BOOL test_lbuttondown_flag; static HWND hwndMessage; @@ -5529,6 +5530,48 @@ static void test_handles( HWND full_hwnd ) #endif } +static void test_winregion(void) +{ + HWND hwnd; + RECT r; + int ret; + HRGN hrgn; + + if (!pGetWindowRgnBox) + { + win_skip("GetWindowRgnBox not supported\n"); + return; + } + + hwnd = CreateWindowExA(0, "static", NULL, WS_VISIBLE, 10, 10, 10, 10, NULL, 0, 0, NULL); + /* NULL prect */ + SetLastError(0xdeadbeef); + ret = pGetWindowRgnBox(hwnd, NULL); + ok( ret == ERROR, "Expected ERROR, got %d\n", ret); + ok( GetLastError() == 0xdeadbeef, "Expected , got %d\n", GetLastError()); + + hrgn = CreateRectRgn(2, 3, 10, 15); + ok( hrgn != NULL, "Region creation failed\n"); + if (hrgn) + { + SetWindowRgn(hwnd, hrgn, FALSE); + + SetLastError(0xdeadbeef); + ret = pGetWindowRgnBox(hwnd, NULL); + ok( ret == ERROR, "Expected ERROR, got %d\n", ret); + ok( GetLastError() == 0xdeadbeef, "Expected , got %d\n", GetLastError()); + + r.left = r.top = r.right = r.bottom = 0; + ret = pGetWindowRgnBox(hwnd, &r); + ok( ret == SIMPLEREGION, "Expected SIMPLEREGION, got %d\n", ret); + ok( r.left == 2 && r.top == 3 && r.right == 10 && r.bottom == 15, + "Expected (2,3,10,15), got (%d,%d,%d,%d)\n", r.left, r.top, + r.right, r.bottom); + DeleteObject(hrgn); + } + DestroyWindow(hwnd); +} + START_TEST(win) { HMODULE user32 = GetModuleHandleA( "user32.dll" ); @@ -5539,6 +5582,7 @@ START_TEST(win) pSetLayeredWindowAttributes = (void *)GetProcAddress( user32, "SetLayeredWindowAttributes" ); pGetMonitorInfoA = (void *)GetProcAddress( user32, "GetMonitorInfoA" ); pMonitorFromPoint = (void *)GetProcAddress( user32, "MonitorFromPoint" ); + pGetWindowRgnBox = (void *)GetProcAddress( user32, "GetWindowRgnBox" ); if (!RegisterWindowClasses()) assert(0); @@ -5608,6 +5652,7 @@ START_TEST(win) test_SetForegroundWindow(hwndMain); test_shell_window(); test_handles( hwndMain ); + test_winregion(); /* add the tests above this line */ if (hhook) UnhookWindowsHookEx(hhook); diff --git a/dlls/user32/user32.spec b/dlls/user32/user32.spec index 8d5571705be..8efdf0aec0f 100644 --- a/dlls/user32/user32.spec +++ b/dlls/user32/user32.spec @@ -385,7 +385,7 @@ @ stdcall GetWindowPlacement(long ptr) @ stdcall GetWindowRect(long ptr) @ stdcall GetWindowRgn(long long) -# @ stub GetWindowRgnBox +@ stdcall GetWindowRgnBox(long ptr) @ stdcall GetWindowTextA(long ptr long) @ stdcall GetWindowTextLengthA(long) @ stdcall GetWindowTextLengthW(long) diff --git a/dlls/user32/winpos.c b/dlls/user32/winpos.c index 42904d98cd0..7f18da51952 100644 --- a/dlls/user32/winpos.c +++ b/dlls/user32/winpos.c @@ -155,6 +155,26 @@ int WINAPI GetWindowRgn ( HWND hwnd, HRGN hrgn ) return nRet; } +/*********************************************************************** + * GetWindowRgnBox (USER32.@) + */ +int WINAPI GetWindowRgnBox( HWND hwnd, LPRECT prect ) +{ + int ret = ERROR; + HRGN hrgn; + + if (!prect) + return ERROR; + + if ((hrgn = CreateRectRgn(0, 0, 0, 0))) + { + if ((ret = GetWindowRgn( hwnd, hrgn )) != ERROR ) + ret = GetRgnBox( hrgn, prect ); + DeleteObject(hrgn); + } + + return ret; +} /*********************************************************************** * SetWindowRgn (USER32.@)