ResizeGadget()

Syntax

ResizeGadget(#Gadget, x, y, Width, Height)
Description
Resize the specified gadget to the given position and dimensions.

Parameters

#Gadget The gadget to resize.
x, y, Width, Height The new position and dimensions of the gadget. To ease the building of real-time resizable Graphical User Interfaces (GUIs), #PB_Ignore can be passed as any parameter (x, y, Width or Height) and this parameter will not be changed.

Return value

None.

Example: Resize gadgets according to new window size

  Procedure SizeHandler()
    ResizeGadget(0, #PB_Ignore, #PB_Ignore, WindowWidth(0) - 20, WindowHeight(0) - 60) 
    ResizeGadget(1, #PB_Ignore, WindowHeight(0) - 40, WindowWidth(0) - 20, #PB_Ignore) 
  EndProcedure
  
  If OpenWindow(0, 0, 0, 220, 100, "Resize the window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_SizeGadget)
    WindowBounds(0, WindowWidth(0), WindowHeight(0), #PB_Ignore, #PB_Ignore)
  
    EditorGadget(0, 10, 10, WindowWidth(0) - 20, WindowHeight(0) - 60)
    ButtonGadget(1, 10, WindowHeight(0) - 40, WindowWidth(0) - 20, 30, "Button")
    
    ; Use BindEvent() to have a realtime gadget resize
    BindEvent(#PB_Event_SizeWindow, @SizeHandler())
    
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          End
      EndSelect
    ForEver
  EndIf

See Also

GadgetX(), GadgetY(), GadgetWidth(), GadgetHeight()

Supported OS

All

<- RemoveGadgetItem() - Gadget Index - ScrollAreaGadget() ->