Important: The information in this document is obsolete and should not be used for new development.
PATH![]() |
![]() ![]() |
The following Control Manager functions for accessing and changing control settings and data are new, changed, or not recommended with Appearance Manager 1.0:
GetBestControlRect
obtains a control's optimal size and text placement. New with Appearance Manager 1.0.SetControlAction
sets or changes the action function for a control. Changed with Appearance Manager 1.0.SetControlColor
customizes the color table for a control. Not recommended with Appearance Manager 1.0.SetControlData
sets control-specific data. New with Appearance Manager 1.0.GetControlData
obtains control-specific data. New with Appearance Manager 1.0.GetControlDataSize
obtains the size of a control's tagged data. New with Appearance Manager 1.0.GetControlFeatures
obtains the features a control supports. New with Appearance Manager 1.0.SetControlFontStyle
sets the font style for a control. New with Appearance Manager 1.0.SetControlVisibility
sets the visibility of a control, and any embedded controls, and specifies whether it should be drawn. New with Appearance Manager 1.0.IsControlVisible
returns whether a control is visible. New with Appearance Manager 1.0.Obtains a control's optimal size and text placement.
pascal OSErr GetBestControlRect (
ControlHandle inControl,
Rect *outRect,
SInt16 *outBaseLineOffset);
inControl
outRect
outBaseLineOffset
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.
Available with Appearance Manager 1.0 and later.
Sets or changes the action function for a control.
pascal void SetControlAction (
ControlHandle theControl,
ControlActionUPP actionProc);
The SetControlAction
function changes the contrlAction
field of the control structure to point to the action function specified in the actionProc
parameter. If the cursor is in the specified control, HandleControlClick
or
TrackControl
call this action function when the user holds down the mouse button. You must provide the action function, and it must define some action to perform repeatedly as long as the user holds down the mouse button. HandleControlUnderClick
and TrackControl
always highlight and drag the control as appropriate.
Note
SetControlAction
should be used to set the application-defined action function for providing live feedback for standard system scroll bar controls.
Customizes the color table for a control.
When the Appearance Manager is available and you are using standard controls, colors are determined by the current theme. If you are creating your own control definition function, you can still set your own colors with the SetControlColor
function.
Not recommended with Appearance Manager 1.0 and later.
pascal OSErr SetControlData (
ControlHandle inControl,
ControlPartCode inPart,
ResType inTagName,
Size inSize,
Ptr inData);
inControl
inPart
kControlEntireControl
indicates that either the control has no parts or the data is not tied to any specific part of the control. inTagName
inSize
inData
parameter. For variable-length control data, pass the value returned in the outMaxSize
parameter of GetControlDataSize
in the inSize
parameter. The number of bytes must match the actual data size.inData
SetControlData
, your application is responsible for disposing of this buffer, if necessary, as information is copied by control. errDataNotSupported
indicates that the inTagName
parameter is not valid.
The SetControlData
function sets control-specific data represented by the value in the inTagName
parameter to the data pointed to by the inData
parameter. SetControlData
could be used, for example, to switch a progress indicator from a determinate to indeterminate state. For a list of the control attributes that can be set, see Control Data Tag Constants
.
Obtains control-specific data.
pascal OSErr GetControlData (
ControlHandle inControl,
ControlPartCode inPart,
ResType inTagName,
Size inBufferSize,
Ptr inBuffer,
Size *outActualSize);
inControl
inPart
kControlEntireControl
indicates that either the control has no parts or the data is not tied to any specific part of the control. inTagName
inBufferSize
inBuffer
parameter. For variable-length control data, pass the value returned in the outMaxSize
parameter of GetControlDataSize
in the inBufferSize
parameter. The number of bytes must match the actual data size.inBuffer
nil
on input, it is equivalent to calling GetControlDataSize
. The actual size of the control-specific data will be returned in the outActualSize
parameter. For variable-length data, the number of bytes must match the actual data size.outActualSize
Size
value. On return, the value is set to the actual size of the data. errDataNotSupported
indicates that the inTagName
parameter is not valid.
The GetControlData
function will only copy the amount of data specified in the inBufferSize
parameter, but will tell you the actual size of the buffer so you will know if the data was truncated.
Obtains the size of a control's tagged data.
pascal OSErr GetControlDataSize (
ControlHandle inControl,
ControlPartCode inPart,
ResType inTagName,
Size *outMaxSize);
inControl
inPart
kControlEntireControl
indicates that either the control has no parts or the data is not tied to any specific part of the control. inTagName
outMaxSize
Size
value. On return, the value is set to the size (in bytes) of the control's tagged data. This value should be passed to SetControlData
and GetControlData
to allocate a sufficiently large buffer for variable-length data.errDataNotSupported
indicates that the inTagName
parameter is not valid.
Pass the value returned in the outMaxSize
parameter of GetControlDataSize
in the inBufferSize
parameter of SetControlData
and GetControlData
to allocate an adequate buffer for variable-length data.
Available with Appearance Manager 1.0 and later.
Obtains the features a control supports.
pascal OSErr GetControlFeatures (
ControlHandle inControl,
UInt32 *outFeatures);
inControl
outFeatures
errMsgNotSupported
indicates that the control does not support Appearance-compliant features.
The GetControlFeatures
function obtains the Appearance-compliant features a control definition function supports, in response to a kControlMsgGetFeatures
message.
Available with Appearance Manager 1.0 and later.
Sets the font style for a control.
pascal OSErr SetControlFontStyle (
ControlHandle inControl,
const ControlFontStyleRec *inStyle);
inControl
inStyle
ControlFontStyleRec
structure. If the flags
field is cleared, the control uses the system font unless the control variant kControlUsesOwningWindowsFontVariant
has been specified (control uses window font).
The SetControlFontStyle
function sets the font style for a given control. To specify the font for controls in a dialog box, it is generally easier to use the dialog font table resource. SetControlFontStyle
allows you to override a control's default font (system or window font, depending upon whether the control variant kControlUsesOwningWindowsFontVariant
has been specified). Once you have set a control's font with this function, you can cause the control to revert to its default font by passing a control font style structure with a cleared flags
field in the inStyle
parameter.
Available with Appearance Manager 1.0 and later.
Sets the visibility of a control, and any embedded controls, and specifies whether it should be drawn.
pascal OSErr SetControlVisibility (
ControlHandle inControl,
Boolean inIsVisible,
Boolean inDoDraw);
inControl
inIsVisible
true
, the control will be visible. If false
, the control will be invisible. If you wish to show a control (and latent embedded subcontrols) but do not want to cause screen drawing, pass true
for this parameter and false in the inDoDraw
parameter. inDoDraw
true
, the control's display on the screen should be updated (drawn or erased) based on the value passed in the inIsVisible
parameter. If false
, the display will not be updated.
You should call the SetControlVisibility
function instead of setting the contrlVis
field of the control structure to set the visibility of a control and specify whether it will be drawn. If the control has embedded controls, SetControlVisibility
allows you to set their visibility and specify whether or not they will be drawn. If you wish to show a control but do not want it to be drawn onscreen, pass true
in the inIsVisible
parameter and false in the inDoDraw
parameter.
Available with Appearance Manager 1.0 and later.
Returns whether a control is visible.
pascal Boolean IsControlVisible (ControlHandle inControl);