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.
| Value | Anchor point | Button grows toward |
|---|---|---|
| SFTBUTTON_AUTOSIZE_NONE (0) | - (disabled) | - |
| SFTBUTTON_AUTOSIZE_TOPLEFT | Top-left corner | Right and down |
| SFTBUTTON_AUTOSIZE_TOPRIGHT | Top-right corner | Left and down |
| SFTBUTTON_AUTOSIZE_BOTTOMLEFT | Bottom-left corner | Right and up |
| SFTBUTTON_AUTOSIZE_BOTTOMRIGHT | Bottom-right corner | Left and up |
| SFTBUTTON_AUTOSIZE_TOPCENTER | Top edge, horizontally centered | Down, growing symmetrically from center |
| SFTBUTTON_AUTOSIZE_BOTTOMCENTER | Bottom edge, horizontally centered | Up, growing symmetrically from center |
| SFTBUTTON_AUTOSIZE_LEFTCENTER | Left edge, vertically centered | Right, growing symmetrically from center |
| SFTBUTTON_AUTOSIZE_RIGHTCENTER | Right edge, vertically centered | Left, growing symmetrically from center |
| SFTBUTTON_AUTOSIZE_CENTER | Current center | Symmetrically 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 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.
If the parent repositions the button (MoveWindow / SetWindowPos), the anchor is updated to match the new rectangle.