Syntax
Window = CreateWindow(x, y, Width, Height, Title$="", Flags=#PG_Window_Default, ParentWindowID=0)
Description
Creates a new ProGUI window. This is the primary container for layouts and widgets. The window is initially created invisible and requires WindowShow() to be made visible. Each created window automatically has a root layout container associated with it, accessible via WindowGetLayout().
The window coordinates and dimensions (`x`, `y`, `Width`, `Height`) are specified in device-independent units (DIPs) based on the default screen DPI (usually 96 DPI). ProGUI handles DPI scaling internally for rendering and layout.
Parameters
x
The initial horizontal position of the window's client area (top-left corner)
in DIPs relative to the screen or parent window.
y
The initial vertical position of the window's client area (top-left corner) in
DIPs relative to the screen or parent window.
Width
The initial width of the window's client area in DIPs.
Height
The initial height of the window's client area in DIPs.
Title$ (optional)
The text displayed in the window's title bar. Default is "".
Flags (optional)
A combination of flags to customize the window's appearance and
behavior. Default is #PG_Window_Default (standard window).
#PG_Window_MinimizeWidget : Adds a minimize gadget to the window frame.
#PG_Window_MaximizeWidget : Adds a maximize gadget to the window frame.
#PG_Window_Minimize : Creates the window initially minimized.
#PG_Window_Maximize : Creates the window initially maximized.
#PG_Window_Sizeable : Allows the user to resize the window.
#PG_Window_Borderless : Creates a window without standard borders or title bar.
#PG_Window_BackgroundDrag : (Windows only) Allows moving a borderless window by clicking and dragging its background (if no widget captures the mouse).
#PG_Window_LayoutFlex : Sets the window's root layout type to Flexbox immediately upon creation.
#PG_Window_LayoutGrid : Sets the window's root layout type to Grid immediately upon creation.
#PG_Window_Default ; #PG_Window_MinimizeWidget | #PG_Window_MaximizeWidget | #PG_Window_Sizeable
ParentWindowID (optional)
The operating system handle (HWND on Windows, GtkWindow
pointer on Linux) of a parent window. If specified, the new window becomes a child window. Default
is 0 (creates a top-level window).
Return Value
Returns a handle to the newly created ProGUI window object if successful, or #Null if the
window could not
be created. This handle is used in subsequent window-related commands.
Remarks
The created window is initially hidden. Use WindowShow() to make it
visible.
Borderless windows might require custom handling for dragging and resizing, although
#PG_Window_BackgroundDrag and internal borderless resizing logic (on Windows) provide some
assistance.
The coordinate system used by ProGUI is based on Device Independent Pixels (DIPs) scaled from a base of
96 DPI. Use WindowGetDpiScaleX() / WindowGetDpiScaleY() to get the current scaling factor.
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
; Create a standard, sizeable window
MyWindow = CreateWindow(100, 100, 640, 480, "My ProGUI App", #PG_Window_MinimizeWidget | #PG_Window_MaximizeWidget | #PG_Window_Sizeable)
If MyWindow
; Add widgets or layouts to WindowGetLayout(MyWindow)
; ...
; Show the window centered on the screen
WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)
; Main event loop
Repeat
Event = WaitWindowEvent()
Until Event = #PB_Event_CloseWindow
EndIf
StopProGUI()
See Also
WindowShow, WindowGetLayout, WindowResize, WindowSetTitle, WindowGetID
Supported OS
Windows, Linux