Vitaliy Margolen : user: Don't drop owned windows in WIN_EnumChildWindows.

Alexandre Julliard julliard at wine.codeweavers.com
Wed Jan 25 09:04:30 CST 2006


Module: wine
Branch: refs/heads/master
Commit: dd57bbd1d2135d406f4cca60dca369ac6fe9aff5
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=dd57bbd1d2135d406f4cca60dca369ac6fe9aff5

Author: Vitaliy Margolen <wine-patch at kievinfo.com>
Date:   Wed Jan 25 15:07:02 2006 +0100

user: Don't drop owned windows in WIN_EnumChildWindows.
Add a few tests for this.

---

 dlls/user/tests/win.c |   46 +++++++++++++++++++++++++++++++++++++++++++++-
 dlls/user/win.c       |    2 --
 2 files changed, 45 insertions(+), 3 deletions(-)

diff --git a/dlls/user/tests/win.c b/dlls/user/tests/win.c
index 64525c4..d4045b1 100644
--- a/dlls/user/tests/win.c
+++ b/dlls/user/tests/win.c
@@ -94,6 +94,14 @@ BOOL CALLBACK EnumChildProc( HWND hwndCh
     return TRUE;
 }
 
+/* will search for the given window */
+BOOL CALLBACK EnumChildProc1( HWND hwndChild, LPARAM lParam) 
+{
+    trace("EnumChildProc1 on %p\n", hwndChild);
+    if ((HWND)lParam == hwndChild) return FALSE;
+    return TRUE;
+}
+
 static HWND create_tool_window( LONG style, HWND parent )
 {
     HWND ret = CreateWindowExA(0, "ToolWindowClass", "Tool window 1", style,
@@ -451,7 +459,9 @@ static void test_parent_owner(void)
 
 
     owner = create_tool_window( WS_OVERLAPPED, 0 );
-    test = create_tool_window( WS_POPUP, NULL );
+    test = create_tool_window( WS_POPUP, desktop );
+
+    ok( !GetWindow( test, GW_OWNER ), "Wrong owner window\n" );
     numChildren = 0;
     ok( !EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ),
         "EnumChildWindows should have returned FALSE\n" );
@@ -471,6 +481,40 @@ static void test_parent_owner(void)
     ok( !EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ),
         "EnumChildWindows should have returned FALSE\n" );
     ok( numChildren == 2, "numChildren should be 2 got %d\n", numChildren );
+    DestroyWindow( child );
+
+    child = create_tool_window( WS_VISIBLE | WS_OVERLAPPEDWINDOW, owner );
+    ok( GetWindow( child, GW_OWNER ) == owner, "Wrong owner window\n" );
+    numChildren = 0;
+    ok( EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ),
+        "EnumChildWindows should have returned TRUE\n" );
+    ok( numChildren == 1, "numChildren should be 1 got %d\n", numChildren );
+
+    ret = SetParent( child, owner );
+    ok( GetWindow( child, GW_OWNER ) == owner, "Wrong owner window\n" );
+    ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop );
+    numChildren = 0;
+    ok( !EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ),
+        "EnumChildWindows should have returned FALSE\n" );
+    ok( numChildren == 2, "numChildren should be 2 got %d\n", numChildren );
+
+    ret = SetParent( child, NULL );
+    ok( GetWindow( child, GW_OWNER ) == owner, "Wrong owner window\n" );
+    ok( ret == owner, "SetParent return value %p expected %p\n", ret, owner );
+    numChildren = 0;
+    ok( EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ),
+        "EnumChildWindows should have returned TRUE\n" );
+    ok( numChildren == 1, "numChildren should be 1 got %d\n", numChildren );
+
+    /* even GW_OWNER == owner it's still a desktop's child */
+    ok( !EnumChildWindows( desktop, EnumChildProc1, (LPARAM)child ),
+        "EnumChildWindows should have found %p and returned FALSE\n", child );
+
+    DestroyWindow( child );
+    child = create_tool_window( WS_VISIBLE | WS_OVERLAPPEDWINDOW, NULL );
+
+    ok( !EnumChildWindows( desktop, EnumChildProc1, (LPARAM)child ),
+        "EnumChildWindows should have found %p and returned FALSE\n", child );
 
     DestroyWindow( child );
     DestroyWindow( test );
diff --git a/dlls/user/win.c b/dlls/user/win.c
index 2f26cd7..237deeb 100644
--- a/dlls/user/win.c
+++ b/dlls/user/win.c
@@ -2812,8 +2812,6 @@ static BOOL WIN_EnumChildWindows( HWND *
     {
         /* Make sure that the window still exists */
         if (!IsWindow( *list )) continue;
-        /* skip owned windows */
-        if (GetWindow( *list, GW_OWNER )) continue;
         /* Build children list first */
         childList = WIN_ListChildren( *list );
 




More information about the wine-cvs mailing list