Ahhh.. yes... your concept of child window is wrong.
If we add a button...
Code: Select all
Procedure.l EnumProcedure(WindowHandle.l, Parameter.l)
Protected cTitle.s = Space(200)
GetWindowText_(WindowHandle, @cTitle, 200)
If Len(Trim(cTitle))>0
Debug Trim(cTitle)
EndIf
ProcedureReturn #True ; Keep enumerating
EndProcedure
Procedure test(n)
Delay(1000) ; just wait for msgbox to display
Debug "Enumerating child windows"
EnumChildWindows_(WindowID(0),@EnumProcedure(), 0)
EndProcedure
OpenWindow(0,10,10,100,100,"Parent", #PB_Window_MinimizeGadget)
ButtonGadget(2,10,10,100,20, "Button") ; <---- added a button (this is a child)
OpenWindow(1,100,100,20,20,"Child",#PB_Window_MinimizeGadget,WindowID(0))
CreateThread(@test(),0)
MessageBox_(WindowID(1),"test","test",0)
API docs wrote:
The EnumChildWindows function does not enumerate top-level windows owned by the specified window, nor does it enumerate any other owned windows
The button is enumerated, so that's the reason.
I looked at the actual styles and the only child of the first window is the button.
The confusion is probably generated by this:
Code: Select all
OpenWindow(1,10,10,20,20,"Child",0,WindowID(0))
The last param means window 0 is the "owner" of window 1, not that window 1 is the "child" of window 0.
To confirm this, look at the help of CreateWindowEx_()
API docs wrote:
hWndParent
Identifies the parent or owner window of the window being created. A valid window handle must be supplied when a child window or an owned window is created. A child window is confined to the client area of its parent window. An owned window is an overlapped window that is destroyed when its owner window is destroyed or hidden when its owner is minimized; it is always displayed on top of its owner window. Although this parameter must specify a valid handle if the dwStyle parameter includes the WS_CHILD style, it is optional if dwStyle includes the WS_POPUP style.