FreeWindow

Syntax

Success = FreeWindow(Window)

Description

Destroys the window, freeing all memory, nested layouts, and widgets attached to it.

Parameters

Window
The handle of the window to free.

Return Value

Returns #True if the window was successfully freed, or #False if the handle was invalid.

Remarks

Calling FreeWindow automatically propagates destruction down to every widget and element housed within the window’s layout, cleaning up memory references and UI resources. The function dispatches a #PG_Event_Destroy event to the window so internal resources and custom user data structures can be cleaned up cleanly. If called inside an active layout or mouse event dispatch loop for this window, the destruction is deferred until the event cycle safely concludes to prevent memory access violations.

See Also

CreateWindow, WindowIsValid

Supported OS

Windows, Linux