Syntax
Window = WidgetGetParentWindow(Widget)Description
Retrieves the handle of the ProGUI window that ultimately contains the specified widget.
Parameters
Widget
The handle of the ProGUI widget whose parent window is to be
retrieved.
Return Value
Returns the handle to the parent ProGUI window object if successful,
or #Null if the widget handle is invalid or not associated
with a window (which shouldn't normally happen for a valid widget).
Remarks
This function traverses the layout hierarchy upwards from the widget until it finds the root window container. It's useful when a widget needs to interact with or get information from the window it belongs to.
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
; Event handler that uses the parent window
Procedure WidgetClickHandler(Widget, EventType, *EventData, *UserData)
ParentWindow = WidgetGetParentWindow(Widget)
If ParentWindow
OldTitle$ = WindowGetTitle(ParentWindow)
WindowSetTitle(ParentWindow, OldTitle$ + " Clicked!")
Debug "Changed parent window title."
EndIf
EndProcedure
MyWindow = CreateWindow(0, 0, 300, 200, "Parent Window")
LayoutSetPadding(#Null, 10) ; Set the current layout padding
If MyWindow
MyButton = CreateButton(0, 0, 100, 30, "Click me!")
WidgetSetMargin(MyButton, 5)
AddEventHandler(MyButton, #PG_Event_Action, @WidgetClickHandler())
WindowShow(MyWindow, #True, #PG_WindowShow_ScreenCentered)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
StopProGUI()See Also
CreateWidget, CreateWindow, WindowGetLayout
Supported OS
Windows, Linux