Gets the size of the button that best fits its text and image, if an image list is present. You can send this message explicitly or use the Button_GetIdealSize macro.



Not used; must be zero.


A pointer to a SIZE structure that receives the desired size of the button, including text and image list, if present. The calling application is responsible for allocating this structure. Set the cx and cy members to zero to have the ideal height and width returned in the SIZE structure. To specify a button width, set the cx member to the desired button width. The system will calculate the ideal height for this width and return it in the cy member.

Return value

If the message succeeds, it returns TRUE. Otherwise it returns FALSE.


Note   If no special button width is desired, then you must set both members of SIZE to zero to calculate and return the ideal height and width. If the value of the cx member is greater than zero, then this value is considered the desired button width, and the ideal height for this width is calculated and returned in the cy member.

This message is most applicable to PushButtons. When sent to a PushButton, the message retrieves the bounding rectangle required to display the button's text. Additionally, if the PushButton has an image list, the bounding rectangle is also sized to include the button's image.

When sent to a button of any other type, the size of the control's window rectangle is retrieved.

Note  To use this message, you must provide a manifest specifying Comclt32.dll version 6.0. For more information on manifests, see Enabling Visual Styles.


Minimum supported client

Windows Vista [desktop apps only]

Minimum supported server

Windows Server 2003 [desktop apps only]