Important: The information in this document is obsolete and should not be used for new development.
GetNewControl
To create a control from a description in a control resource ('CNTL'), use the GetNewControl function.
FUNCTION GetNewControl (controlID: Integer; owner: WindowPtr) : ControlHandle;
controlID- The resource ID of a control resource.
owner- A pointer to the window in which you want to attach the control.
DESCRIPTION
TheGetNewControlfunction creates a control record from the information in the specified control resource, adds the control record to the control list for the specified window, and returns as its function result a handle to the control. You use this handle when referring to the control in most other Control Manager routines. After making a copy of the control resource,GetNewControlreleases the memory occupied by the original control resource before returning.If you provide a control color table resource with the same resource ID as the control resource,
GetNewControlcreates an auxiliary control record that uses the colors you specify in your control color table resource. If you don't provide a control color table,GetNewControlcreates an auxiliary control record that uses the default control color table if the computer is running in 32-bit mode.The control resource specifies the rectangle for the control, its initial setting, its visibility state, its maximum and minimum settings, its control definition ID, a reference value, and its title (if any). After you use
GetNewControlto create the control, you can change the current setting, the maximum setting, the minimum setting, the reference value, and the title by using, respectively, theSetControlValue,SetControlMaximum,SetControlMinimum,SetControlReference, andSetControlTitleprocedures. You can use theMoveControlandSizeControlprocedures to change the control's rectangle. You can use theGetControlValue,GetControlMaximum,GetControlMinimum,GetControlReference, andGetControlTitlefunctions to determine the control values.If the control resource specifies that the control should be visible, the Control Manager draws the control. If the control resource specifies that the control should initially be invisible, you can use the
ShowControl procedure to make the control visible.If
GetNewControlcan't read the control resource from the resource file,GetNewControlreturnsNIL.SEE ALSO
See Listing 5-1 on page 5-15 and Listing 5-5 on page 5-21 for examples of how to useGetNewControlto create, respectively, a button and a scroll bar. For information about windows' control lists, see the chapter "Window Manager" in this book.