WindowResize

Syntax

Success = WindowResize(Window, x, y, Width, Height)

Description

Queues a request to resize and/or move the specified window to the given screen coordinates and dimensions. The actual resize operation is performed asynchronously by the ProGUI render thread.

The coordinates and dimensions (`x`, `y`, `Width`, `Height`) are specified in physical screen pixels and refer to the window's outer frame (including borders and title bar).

Parameters

Window
The handle of the ProGUI window to resize or move.

x
The new horizontal screen coordinate (in pixels) for the window's top-left corner (outer frame). Use #PG_Ignore to keep the current X position.

y
The new vertical screen coordinate (in pixels) for the window's top-left corner (outer frame). Use #PG_Ignore to keep the current Y position.

Width
The new width (in pixels) for the window's outer frame. Use #PG_Ignore to keep the current width.

Height
The new height (in pixels) for the window's outer frame. Use #PG_Ignore to keep the current height.

Return Value

Returns #True if the resize request was successfully queued, or #False if the window handle was invalid.

Remarks

This function is asynchronous. It flags the window as needing a resize/move, which is handled later by the render thread. It does not block execution. Note that the dimensions and coordinates are for the outer window frame in physical pixels, unlike CreateWindow() which uses client area dimensions in DIPs. On Windows, resizing for borderless windows might use a double-buffering technique (#_EnableDoubleBufferResizing = #True) involving a second hidden window to reduce flicker during resizing operations initiated by dragging the borderless frame.

Example

IncludeFile "ProGUI_PB.pbi"

StartProGUI()

; Event handler to trigger the resize after animation ends
Procedure DelayedResizeHandler(Window, EventType, *EventData.PG_EventAnimate, *UserData)
  If EventType = #PG_Event_Animate And *EventData\state = #PG_Event_Animate_End
    Debug "Animation finished, resizing window..."
    ; Resize the window (keeping its current position)
    WindowResize(Window, #PG_Ignore, #PG_Ignore, 600, 400)
  EndIf
EndProcedure

MyWindow = CreateWindow(0, 0, 400, 300, "Resize Example")

If MyWindow
  AddEventHandler(MyWindow, #PG_Event_Animate, @DelayedResizeHandler()) ; Add handler for animation end
  WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)

  Debug "Window shown, waiting 2 seconds via animation before resize..."
  ; Start a 2-second animation. When it ends, the handler will trigger the resize.
  StartAnimation(MyWindow, 1, 2000) ; ID 1, Duration 2000ms

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

StopProGUI()

See Also

CreateWindow, WindowGetWidth, WindowGetHeight, WindowGetX, WindowGetY, StartAnimation, AddEventHandler

Supported OS

Windows, Linux