[Bug 3928] EnunChildWindows fails to find a child window who did setParent

Wine Bugs wine-bugs at winehq.org
Tue Nov 29 09:08:53 CST 2005


------- Additional Comments From andrew7webb at comcast.net  2005-29-11 09:08 -------
Thanks for your tests and bug fix for the status return.  We are getting very 

Your test creates two windows:

    test = create_tool_window( WS_POPUP, NULL );
    child = create_tool_window( WS_CHILD, owner );

    numChildren = 0;
    ok( !EnumChildWindows( owner, EnumChildProc, (LPARAM)&numChildren ),
        "EnumChildWindows should have teruned FALSE\n" );
    ok( numChildren == 2, "numChildren should be 2 got %d\n", numChildren );

If you add a third window as:

    ownedWin = create_tool_window( WS_VISIBLE | WS_OVERLAPPEDWINDOW, owner );

and then check:

    ok( numChildren == 3, "numChildren should be 3 got %d\n", numChildren );

I think you will reproduce the problem, as this is how the original test case 
window is created. 

My theory for why your tests did not reproduce the problem is:
"create_tool_window( WS_CHILD, owner )" does not create an "owned window" 
because it passes a WS_CHILD which CreateWindow interprests as overruling the 
passed owner.  There is code in win.c that enforces this:

913:    owner= 0;

930:    if ( (cs->style & (WS_CHILD|WS_POPUP)) == WS_CHILD)
           parent= WIN_GetFullHandle( cs->hwndParent );
           owner= GetAncester( cs->hwndParent, GA_ROOT );

962:    wndPtr->owner= owner;

So a window with WS_CHILD will have a 0 ->owner, and thus 
      HWND own= GetWindow( handle(), GW_OWNER );
will return 0.

The code is consistent with the windows documentation statement:  
"Only an overlapped or pop-up window can be an owner window; a child window 
cannot be an owner window."  (See below excerpt)

Owned Windows
An overlapped or pop-up window can be owned by another overlapped or pop-up 
window. Being owned places several constraints on a window.

An owned window is always above its owner in the z-order. 
The system automatically destroys an owned window when its owner is destroyed. 
An owned window is hidden when its owner is minimized. 
Only an overlapped or pop-up window can be an owner window; a child window 
cannot be an owner window. An application creates an owned window by specifying 
the owner's window handle as the hwndParent parameter of CreateWindowEx when it 
creates a window with the WS_OVERLAPPED or WS_POPUP style. The hwndParent 
parameter must identify an overlapped or pop-up window. If hwndParent 
identifies a child window, the system assigns ownership to the top-level parent 
window of the child window. After creating an owned window, an application 
cannot transfer ownership of the window to another window.

Dialog boxes and message boxes are owned windows by default. An application 
specifies the owner window when calling a function that creates a dialog box or 
message box.

An application can use the GetWindow function with the GW_OWNER flag to 
retrieve a handle to a window's owner.


My theory for why WINE differs from Windows remains the same:
line 810 in the dlls/user/win.c function WIN_EnumChildWindows():

     if(GetWindow( *list, GW_OWNER )) continue;

should not be present because it does not allow owned windows to be enumerated, 
and Windows does.

best regards, Andrew

Configure bugmail: http://bugs.winehq.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

More information about the wine-bugs mailing list