Blitz3D+ Command Reference

ButtonPreferredWidth ( button )

Parameters

button - push, default or cancel button handle

Description

Returns the width a button needs for its caption, in logical pixels.

The width fits the current single-line caption, the font and any icon from SetButtonIcon. Styled appearances include horizontal padding on both sides plus the border. Native appearance and high contrast use Windows' ideal size. Access-key markers are measured as displayed.

The button is not resized automatically - apply the size with SetGadgetShape after changing text, font, padding or DPI:

SetGadgetShape button,20,20,ButtonPreferredWidth(button),ButtonPreferredHeight(button)

If deliberately made narrower, styled text is clipped with an ellipsis. Check boxes and radio buttons cause a runtime error.

See the complete 10_Modern_Control_Showcase.bb sample.

Requires Extended mode.

See also: ButtonPreferredHeight, SetButtonAppearance, SetButtonPadding, SetButtonIcon, SetGadgetShape.

Index