HeaderPane
Main
Hide

SftButton/DLL 3.0 - Button Control

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 original bounding 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_CENTEROriginal centerSymmetrically in all directions

The original bounding rectangle is recorded at the moment SFTBUTTON_AUTOSIZE is first set. Subsequent text, image and border changes recompute the optimal size and reposition the button relative to the recorded anchor.

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 04/25/2026 - (email)
© 2026 Softel vdm, Inc.