Syntax
Success = WidgetSetMinWidth(Widget, Width.d)
Description
Sets the minimum width constraint for the specified widget in device-independent pixels (DIPs).
Parameters
Widget
The handle of the ProGUI widget.
Width.d
The minimum width value in DIPs. Use #PG_Widget_FitContent
(-1) to set the minimum width based on the widget's content (e.g., the overflow width of a child
layout). Set to 0 to remove the minimum width constraint.
Return Value
Returns #True if the minimum width was successfully set, or #False if the
widget handle was invalid.
Remarks
The layout engine will not shrink the widget's width below this value, unless the container itself is smaller than the minimum width. This takes precedence over the ideal width if the ideal width is smaller. Setting the minimum width triggers a layout update.
Example
IncludeFile "ProGUI_PB.pbi"
StartProGUI()
MyWindow = CreateWindow(0, 0, 200, 200, "MinWidth Example")
RootLayout = WindowGetLayout(MyWindow)
LayoutSetType(RootLayout, #PG_Layout_Type_Flex)
LayoutSetPadding(RootLayout, 10)
If MyWindow
Widget1 = CreateWidget(0, 0, 150, 50) ; Start wider
WidgetSetClass(Widget1, "widget1")
WidgetSetMinWidth(Widget1, 80) ; Set a minimum width
WidgetSetMargin(Widget1, 5)
WindowShow(MyWindow, #True, #PG_Window_ScreenCentered)
Debug "Initial Widget 1 Width: " + StrD(WidgetGetWidth(Widget1)) ; Should be 150
; Now try to set Widget1's width below its minimum
WidgetSetWidth(Widget1, 30)
Repeat
Event = WaitWindowEvent()
If Event = #PB_Event_LeftClick
Debug "After setting width to 30:"
Debug "Widget 1 Width: " + StrD(WidgetGetWidth(Widget1)) ; Should be clamped to 80 (minWidth)
EndIf
Until Event = #PB_Event_CloseWindow
EndIf
StopProGUI()
See Also
WidgetGetMinWidth, WidgetSetMinHeight, WidgetSetWidth, WidgetGetWidth
Supported OS
Windows, Linux