CButton.GetIdealSizemethod
Gets the size of the button that best fits its text and image, if an image list is present.
Syntax
FUNCTION GetIdealSize (BYVAL hButton AS HWND, BYVAL pSize AS SIZE PTR) AS BOOLEAN
FUNCTION GetIdealSize (BYVAL hButton AS HWND, BYREF sz AS SIZE) AS BOOLEAN
FUNCTION GetIdealSize (BYVAL hButton AS HWND) AS SIZE
Parameters
| Name | Description | |
|---|---|---|
tsize | 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.
Description
Gets the size of the button that best fits its text and image, if an image list is present.
Remarks
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.
To use this message, you must provide a manifest specifying Comclt32.dll version 6.0.
Example
DIM sz AS SIZE DIM res AS BOOLEAN = CButton.GetIdealSize(hButton, @sz) DIM res AS BOOLEAN = CButton.GetIdealSize(hButton, sz) sz = CButton.GetIdealSize(hButton)
Reference
- Include file
CButton.inc - Defined in AfxNova/CButton.inc:380
- Documented in Windows/WIndows Controls/CButton Class.md
- Topic: CButton Class