GetDItem
GetDItem
Obtain dialog item type, handle, and rectangle void GetDItem( theDialog, theItem, iType, iHandle, iRect ); DialogPtr theDialog ; the dialog containing item of interest short theItem ; item number of interest
short *iType ; receives item type of theItem
Handle *iHandle ; receives 4-byte Handle (et al.) of theItem Rect *iRect ; receives 4-byte address of Rect structure GetDItem obtains information about a specified item of a specified dialog - its item type, a handle to its data, and the size and position of its enclosing
rectangle. It can be used to get the current values before using SetDItem to change them. This function MUST be used before you call GetIText or SetIText (which examine or modify the text of editText or statText items). theDialog is the address of a 170-byte DialogRecord structure. It identifies which dialog contains the item you wish to query. It is actually a
theItem is the item number of the item to query. Item numbers start with 1
and are in the order of the item list, as defined in a 'DITL' resource.
iType is the address of a 16-bit integer. Upon return it will contain the
item type - a value defining the attributes of the item. See Notes,
below.
iHandle is the address of a 4-byte Handle. Upon return, its data type will
vary, depending on the return value of the low 7 bits of iType. See
Notes.
iRect is the address of an 8-byte Rect structure. Upon return, the Rect it will identify the item's enclosing rectangle, in coordinates local to
theDialog 's window.
Notes: GetDItem is used to glean information about an item in a dialog. For instance, you must use this to obtain the handle of a control whose title you
wish to modify. Also, if you wish to disable an item or reposition it, etc., the
only way to do so is via SetDItem, which expects valid values in its parameters. Use GetDItem to get the current values before calling The following table shows the various values returned in iType and the
data types you can expect in iHandle :
iType iHandle Description
proc.
4 + btnCtrl (0) a push button control
4 + chkCtrl (1) a check box control
4 + radCtrl (2) a radio button control
4 + resCtrl (3) other control ('CDEF' resource)
statText (8) Handle leading to static text editText (16) Handle value of an hText field of a TERec iconItem (32) Handle leading to 128-byte icon itemDisable (128) (one of above) theItem is currently disabled
For instance, to change the title of a check box control (e.g., item 3 in
theDlg ), use:
short iType;
GetDItem( theDlg, 3, &iType, &iHandle, &iRect); SetCTitle( iHandle, "\pDon't use Big Letters" ); To set the default in an editable text item (e.g., item 7 in theDlg ) to the
value "Un titled", use:
short iType;
GetDItem( theDlg, 7, &iType, &iHandle, &iRect); SelIText( theDlg, 7, 0,32767 ); /* pre-select the name */