WindowGetLayout

Syntax

Layout = WindowGetLayout(Window)

Description

Retrieves the handle to the root layout container associated with the specified ProGUI window. Every ProGUI window automatically has a main layout created for it upon window creation.

Parameters

Window
The handle of the ProGUI window whose root layout is to be retrieved.

Return Value

Returns the handle to the root layout object if the window handle is valid. Returns #Null or #False on error.

Remarks

This layout serves as the primary container for adding widgets and other nested layouts directly to the window. You can modify its type (e.g., to Flex or Grid) using LayoutSetType() or by specifying flags during CreateWindow().

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

MyWindow = CreateWindow(0, 0, 500, 400, "Window Layout")

If MyWindow
  RootLayout = WindowGetLayout(MyWindow)
  If RootLayout
    ; Set the root layout to Flexbox
    LayoutSetType(RootLayout, #PG_Layout_Type_Flex)
    LayoutFlexSetDirection(RootLayout, #PG_Flex_Direction_Column)
    LayoutSetPadding(RootLayout, 20) ; Add padding

    ; Add a widget to the root layout
    MyWidget = CreateWidget(0, 0, 100, 30)
    WidgetSetClass(MyWidget, "button") ; Assume a skin defines "button"
    WidgetSetMargin(MyWidget, 10)
    ; ... further widget setup ...
  EndIf

  WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)

  Repeat
    Event = WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow
EndIf

StopProGUI()

See Also

CreateWindow, LayoutSetType, LayoutAddWidget

Supported OS

Windows, Linux