HeaderPane
Main
Hide

SftButton/DLL 3.0 - Button Control

Share Link
Print

CalcOptimalSize

Compute the optimal width and height for the button given its current images, text, border and theme settings. Does not resize the button.

C

void SftButton_CalcOptimalSize(HWND hwndCtl, int *width, int *height);

C++

void CSftButton::CalcOptimalSize(int *width, int *height);

Parameters

hwndCtl

The window handle of the button control.

width, height

Pointers to int that receive the optimal width and height in pixels. Either may be NULL if the caller is not interested in that dimension.

Comments

CalcOptimalSize is useful when laying out a parent dialog around a button, or for deciding how large to make a button that is about to have its images or text replaced. It is also the computation SftButton uses internally when iAutoSize is not SFTBUTTON_AUTOSIZE_NONE - see Auto-Sizing.

The returned values include the border and internal padding. They are in physical pixels for the button's current monitor DPI; if the button later moves to a different-DPI monitor the optimal values change.

See Also C/C++ API | Auto-Sizing


Last Updated 04/25/2026 - (email)
© 2026 Softel vdm, Inc.