![]() |
GetBestControlRect |
||||
Header: | Controls.h | Carbon status: | Supported | |
Obtains a controls optimal size and text placement.
OSErr GetBestControlRect ( ControlRef inControl, Rect *outRect, SInt16 *outBaseLineOffset );
A handle to the control to be examined.
On input, a pointer to an empty rectangle (0, 0, 0, 0). On return, the rectangle is set to the optimal size for the control. If the control doesnt support getting an optimal size rectangle, the controls bounding rectangle is passed back.
On input, a pointer to a signed 16-bit integer value. On return, the value is set to the offset from the bottom of control to the base of the text (usually a negative value). If the control doesnt support optimal sizing or has no text, 0 is passed back.
A result code.
You can call the GetBestControlRect function to automatically position and size controls in accordance with human interface guidelines. This function is particularly helpful in determining the correct placement of control text whose length is not known until run-time. For example, the StandardAlert function uses GetBestControlRect to automatically size and position buttons in a newly created alert box.
This function is available with Appearance Manager 1.0 and later.
Supported in Carbon. Available in Carbon 1.0.2 and later when running Mac OS 8.1 or later.
© 2000 Apple Computer, Inc. (Last Updated 6/30/2000)