Module: wine Branch: master Commit: 367577c0d67c6cbca3d35c6ad119cbf7502c991d URL: http://source.winehq.org/git/wine.git/?a=commit;h=367577c0d67c6cbca3d35c6ad1...
Author: Piotr Caban piotr@codeweavers.com Date: Wed Feb 26 15:40:00 2014 +0100
user32: Check WS_CHILD style in IsChild function.
---
dlls/user32/tests/win.c | 13 +++++++++++++ dlls/user32/win.c | 18 +++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/dlls/user32/tests/win.c b/dlls/user32/tests/win.c index 3c63c8a..d693172 100644 --- a/dlls/user32/tests/win.c +++ b/dlls/user32/tests/win.c @@ -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"); diff --git a/dlls/user32/win.c b/dlls/user32/win.c index d60427f..29f2365 100644 --- a/dlls/user32/win.c +++ b/dlls/user32/win.c @@ -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; }