Page 1 of 1
child window
Posted: Mon Jan 19, 2026 8:36 pm
by mestnyi
Code: Select all
If OpenWindow(1, 100, 200, 195, 260, "1", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
OpenWindow(2, 300, 300, 195, 260, "2", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, WindowID(1))
handle = WindowID(2)
; handle = WindowID(1)
: How do I know if Window 1 has a child window?
; How do I know if Window 2 has a main window or parent window?
Repeat
Until WaitWindowEvent() = PB_Event_CloseWindow
EndIf
End
Re: child window
Posted: Mon Jan 19, 2026 9:00 pm
by RASHAD
Code: Select all
#GA_PARENT = 1
#GA_ROOT = 2
#GA_ROOTOWNER = 3
GetAncestor_(hWnd,Flag)
GetWindow_(hWnd,#GW_CHILD)
Re: child window
Posted: Tue Jan 20, 2026 9:00 am
by mestnyi
first of all, thank you for responding. I think I asked the wrong question first. Now, as for the code, it doesn't return anything useful in this case.
Code: Select all
If OpenWindow(1, 100, 200, 195, 260, "1", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
OpenWindow(2, 200, 200, 195, 260, "2", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, WindowID(1))
OpenWindow(3, 300, 200, 195, 260, "3", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, WindowID(2))
win1 = WindowID(1)
win2 = WindowID(2)
win3 = WindowID(3)
; How do I know If Window 1 has a child window?
; How do I know if Window 2 has a main window or parent window?
Debug "win1 "+win1
Debug "win2 "+win2
Debug "win3 "+win3
Debug ""
Debug "win1 1 "+GetAncestor_(win1,1)
Debug "win2 1 "+GetAncestor_(win2,1)
Debug "win3 1 "+GetAncestor_(win3,1)
Debug ""
Debug "win1 2 "+GetAncestor_(win1,2)
Debug "win2 2 "+GetAncestor_(win2,2)
Debug "win3 2 "+GetAncestor_(win3,2)
Debug ""
Debug "win1 3 "+GetAncestor_(win1,3)
Debug "win2 3 "+GetAncestor_(win2,3)
Debug "win3 3 "+GetAncestor_(win3,3)
Debug ""
Debug "win1 w "+GetWindow_(win1,#GW_CHILD)
Debug "win2 w "+GetWindow_(win2,#GW_CHILD)
Debug "win3 w "+GetWindow_(win3,#GW_CHILD)
Debug IsChild_(win1, win2)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
End
Re: child window
Posted: Tue Jan 20, 2026 9:25 am
by RASHAD
Code: Select all
If OpenWindow(1, 100, 200, 195, 260, "1", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
OpenWindow(2, 200, 200, 195, 260, "2", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, WindowID(1))
OpenWindow(3, 300, 200, 195, 260, "3", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, WindowID(2))
win1 = WindowID(1)
win2 = WindowID(2)
win3 = WindowID(3)
Debug win1
Debug win2
Debug win3
Debug GetWindowLongPtr_(win1,#GWL_HWNDPARENT)
Debug GetWindowLongPtr_(win2,#GWL_HWNDPARENT)
Debug GetWindowLongPtr_(win3,#GWL_HWNDPARENT)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
End
Re: child window
Posted: Tue Jan 20, 2026 9:49 am
by breeze4me
Another way.
Code: Select all
If OpenWindow(1, 100, 200, 195, 260, "1", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget)
OpenWindow(2, 200, 200, 195, 260, "2", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, WindowID(1))
OpenWindow(3, 300, 200, 195, 260, "3", #PB_Window_SystemMenu | #PB_Window_MinimizeGadget | #PB_Window_MaximizeGadget, WindowID(2))
win1 = WindowID(1)
win2 = WindowID(2)
win3 = WindowID(3)
; How do I know If Window 1 has a child window?
; How do I know if Window 2 has a main window or parent window?
Debug "win1 "+win1
Debug "win2 "+win2
Debug "win3 "+win3
Debug ""
#GW_ENABLEDPOPUP = 6
Debug "win1 children = win2,3"
child1 = GetWindow_(win1,#GW_ENABLEDPOPUP)
child2 = GetWindow_(child1,#GW_HWNDNEXT)
Debug child1
Debug child2
Debug "If there are no more children = win1 " + GetWindow_(child2,#GW_HWNDNEXT)
Debug ""
Debug "win1 #GW_OWNER = 0 "+GetWindow_(win1,#GW_OWNER)
Debug "win2 #GW_OWNER = win1 "+GetWindow_(win2,#GW_OWNER)
Debug "win3 #GW_OWNER = win2 "+GetWindow_(win3,#GW_OWNER)
Debug "win2 child = win3 " + GetWindow_(win2,#GW_ENABLEDPOPUP)
Debug "win3 child = 0 " + GetWindow_(win3,#GW_ENABLEDPOPUP)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
End
Re: child window
Posted: Tue Jan 20, 2026 9:57 am
by mestnyi
this is a different story, thank you very much, now all I have to do is find something for Linux
Procedure IsChildWindow( child, parent )
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
If CocoaMessage( 0, child, "parentWindow" ) = parent
ProcedureReturn #True
EndIf
CompilerElseIf #PB_Compiler_OS = #PB_OS_Windows
If GetWindowLongPtr_(child,#GWL_HWNDPARENT) = parent
ProcedureReturn #True
EndIf
CompilerElseIf #PB_Compiler_OS = #PB_OS_Linux
CompilerEndIf
EndProcedure
Re: child window
Posted: Tue Jan 20, 2026 12:20 pm
by mk-soft
Code: Select all
GtkWidget*
gtk_widget_get_parent (
GtkWidget* widget
)
Code: Select all
GdkWindow*
gtk_widget_get_root_window (
GtkWidget* widget
)