HeaderPane
Main
Hide
Share Link
Print

Auto-Sizing

SftButton can automatically resize itself to fit its text and images, re-anchoring to one of nine reference points on its current rectangle. Set iAutoSize on SFTBUTTON_CONTROL to opt in.

Anchor values

ValueAnchor pointButton grows toward
SFTBUTTON_AUTOSIZE_NONE (0)- (disabled)-
SFTBUTTON_AUTOSIZE_TOPLEFTTop-left cornerRight and down
SFTBUTTON_AUTOSIZE_TOPRIGHTTop-right cornerLeft and down
SFTBUTTON_AUTOSIZE_BOTTOMLEFTBottom-left cornerRight and up
SFTBUTTON_AUTOSIZE_BOTTOMRIGHTBottom-right cornerLeft and up
SFTBUTTON_AUTOSIZE_TOPCENTERTop edge, horizontally centeredDown, growing symmetrically from center
SFTBUTTON_AUTOSIZE_BOTTOMCENTERBottom edge, horizontally centeredUp, growing symmetrically from center
SFTBUTTON_AUTOSIZE_LEFTCENTERLeft edge, vertically centeredRight, growing symmetrically from center
SFTBUTTON_AUTOSIZE_RIGHTCENTERRight edge, vertically centeredLeft, growing symmetrically from center
SFTBUTTON_AUTOSIZE_CENTERCurrent centerSymmetrically in all directions

No rectangle is stored. While iAutoSize is not SFTBUTTON_AUTOSIZE_NONE, every change that affects the optimal size (text, images, font, border, theme, or a resize by the parent) resizes the button so the chosen anchor point of its current rectangle stays in place.

SftButton_CalcOptimalSize

SftButton_CalcOptimalSize returns the optimal width and height without actually resizing the button. Useful for laying out the parent dialog before creating the button, or for computing the size of a future button given candidate text / image content.

Interaction with parent-driven resize

If the parent repositions the button (MoveWindow / SetWindowPos), the anchor is updated to match the new rectangle.


Last Updated 10/11/2026 - (email)
© 2026 Softel vdm, Inc.