[3/3] user32: Implemented GetWindowRgnBox with tests
Nikolay Sivov
bunglehead at gmail.com
Wed Apr 1 17:00:31 CDT 2009
IE8 requested this.
Changelog:
- Implemented GetWindowRgnBox with tests
>From 1875d97d5a1eb2af2568f3f514bf07e5e049df0a Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <bunglehead at gmail.com>
Date: Wed, 1 Apr 2009 17:53:12 -0400
Subject: Implemented GetWindowRgnBox
---
dlls/user32/tests/win.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
dlls/user32/user32.spec | 2 +-
dlls/user32/winpos.c | 20 ++++++++++++++++++++
3 files changed, 66 insertions(+), 1 deletions(-)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c
index 89eefcd..d501260 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()
+{
+ HWND hwnd;
+ RECT r;
+ int ret;
+ HRGN hrgn;
+
+ hwnd = CreateWindowExA(0, "static", NULL, WS_VISIBLE, 10, 10, 10, 10, NULL, 0, 0, NULL);
+ if (pGetWindowRgnBox)
+ {
+ /* 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);
+ }
+ }
+ else
+ win_skip("GetWindowRgnBox not supported\n");
+
+ 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 8d55717..8efdf0a 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 42904d9..7f18da5 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.@)
--
1.5.6.5
More information about the wine-patches
mailing list