user32: Verify we got a valid window handle in GetDCEx().

This commit is contained in:
Henri Verbeet 2010-05-19 11:13:38 +02:00 committed by Alexandre Julliard
parent 9d865274c0
commit 2c2e3f8665
2 changed files with 26 additions and 0 deletions

View File

@ -908,6 +908,8 @@ HDC WINAPI GetDCEx( HWND hwnd, HRGN hrgnClip, DWORD flags )
TRACE("hwnd %p, hrgnClip %p, flags %08x\n", hwnd, hrgnClip, flags); TRACE("hwnd %p, hrgnClip %p, flags %08x\n", hwnd, hrgnClip, flags);
if (!IsWindow(hwnd)) return 0;
/* fixup flags */ /* fixup flags */
if (flags & (DCX_WINDOW | DCX_PARENTCLIP)) flags |= DCX_CACHE; if (flags & (DCX_WINDOW | DCX_PARENTCLIP)) flags |= DCX_CACHE;

View File

@ -392,6 +392,23 @@ static void test_invisible_create(void)
DestroyWindow(hwnd_owndc); DestroyWindow(hwnd_owndc);
} }
static void test_destroyed_window(void)
{
HDC dc;
dc = GetDCEx(hwnd_cache, 0, DCX_USESTYLE);
ok(!dc, "Got a non-NULL DC (%p) for a destroyed window.\n", dc);
dc = GetDCEx(hwnd_owndc, 0, DCX_USESTYLE);
ok(!dc, "Got a non-NULL DC (%p) for a destroyed window.\n", dc);
dc = GetDCEx(hwnd_classdc, 0, DCX_USESTYLE);
ok(!dc, "Got a non-NULL DC (%p) for a destroyed window.\n", dc);
dc = GetDCEx(hwnd_classdc2, 0, DCX_USESTYLE);
ok(!dc, "Got a non-NULL DC (%p) for a destroyed window.\n", dc);
}
START_TEST(dce) START_TEST(dce)
{ {
WNDCLASSA cls; WNDCLASSA cls;
@ -431,4 +448,11 @@ START_TEST(dce)
test_dc_visrgn(); test_dc_visrgn();
test_begin_paint(); test_begin_paint();
test_invisible_create(); test_invisible_create();
DestroyWindow(hwnd_classdc2);
DestroyWindow(hwnd_classdc);
DestroyWindow(hwnd_owndc);
DestroyWindow(hwnd_cache);
test_destroyed_window();
} }