Syntax
CurrentLayout = LayoutGetCurrent()
Description
Retrieves the handle of the layout container that is currently designated as the target for adding new widgets.
Parameters
This command takes no parameters.
Return Value
Returns the handle of the current layout object, or #Null if no layout is currently set (which shouldn't normally happen after initialization).
Remarks
When a layout is created using CreateLayout(), it automatically becomes the current layout. The root layout of a window (retrieved via WindowGetLayout()) can also be set as the current layout using LayoutSetCurrent(). This function is useful to get a reference to the active layout before potentially changing it with LayoutPush() or LayoutSetCurrent().
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
MyWindow = CreateWindow(0, 0, 400, 300, "Get Current Layout")
If MyWindow
RootLayout = WindowGetLayout(MyWindow)
LayoutSetCurrent(RootLayout) ; Ensure root is current
InitialCurrent = LayoutGetCurrent()
Debug "Initial Current Layout: " + Str(InitialCurrent)
; Create a new layout, which automatically becomes current
NewLayout = CreateLayout(#PG_Layout_Type_Flex)
Debug "New Layout Handle: " + Str(NewLayout)
Debug "Current Layout After Creation: " + Str(LayoutGetCurrent())
; Restore the initial layout as current
LayoutSetCurrent(InitialCurrent)
Debug "Current Layout After SetCurrent: " + Str(LayoutGetCurrent())
WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
StopProGUI()
See Also
CreateLayout, LayoutSetCurrent, LayoutPush, LayoutPop, WindowGetLayout
Supported OS
Windows, Linux