Commit 367577c0 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

user32: Check WS_CHILD style in IsChild function.

parent c60e81b7
......@@ -3675,6 +3675,19 @@ static void test_SetParent(void)
ok(SetParent(sibling, parent) != 0, "SetParent should not fail\n");
ok(GetMenu(sibling) == hMenu, "SetParent should not remove menu\n");
ok(SetParent(parent, desktop) != 0, "SetParent should not fail\n");
ok(SetParent(child4, child3) != 0, "SetParent should not fail\n");
ok(SetParent(child3, child2) != 0, "SetParent should not fail\n");
ok(SetParent(child2, child1) != 0, "SetParent should not fail\n");
ok(!IsChild(child3, child4), "wrong parent/child %p/%p\n", child3, child4);
SetWindowLongW(child4, GWL_STYLE, WS_CHILD);
ok(IsChild(child3, child4), "wrong parent/child %p/%p\n", child3, child4);
ok(IsChild(child2, child4), "wrong parent/child %p/%p\n", child2, child4);
ok(!IsChild(child1, child4), "wrong parent/child %p/%p\n", child1, child4);
SetWindowLongW(child2, GWL_STYLE, WS_CHILD);
ok(IsChild(child1, child4), "wrong parent/child %p/%p\n", child1, child4);
ok(IsChild(parent, child4), "wrong parent/child %p/%p\n", parent, child4);
ok(DestroyWindow(parent), "DestroyWindow() failed\n");
ok(!IsWindow(parent), "parent still exists\n");
......
......@@ -3043,14 +3043,22 @@ HWND WINAPI SetParent( HWND hwnd, HWND parent )
*/
BOOL WINAPI IsChild( HWND parent, HWND child )
{
HWND *list = list_window_parents( child );
HWND *list;
int i;
BOOL ret;
BOOL ret = FALSE;
if (!list) return FALSE;
if (!(GetWindowLongW( child, GWL_STYLE ) & WS_CHILD)) return FALSE;
if (!(list = list_window_parents( child ))) return FALSE;
parent = WIN_GetFullHandle( parent );
for (i = 0; list[i]; i++) if (list[i] == parent) break;
ret = list[i] && list[i+1];
for (i = 0; list[i]; i++)
{
if (list[i] == parent)
{
ret = list[i] && list[i+1];
break;
}
if (!(GetWindowLongW( list[i], GWL_STYLE ) & WS_CHILD)) break;
}
HeapFree( GetProcessHeap(), 0, list );
return ret;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment