SetDItem
SetDItem Modify dialog item attributes
#include <Dialogs.h> Dialog Manager
void SetDItem( theDialog, theItem, iType, iHandle, iRect );
DialogPtr theDialog ; the dialog containing item of interest
short theItem ; item number of interest
short iType ; desired item type for theItem
Handle iHandle ; desired Handle (or ProcPtr.) for theItem
Rect *iRect ; address of Rect for theItem
SetDItem selects the item type, handle, and enclosing rectangle for a
specified item. Normally you will call GetDItem to obtain current settings
and modify only one or two parameters for use in the function. SetDItem
must NOT be used to move or modify controls or change statText or editText
items.
theDialog is the address of a 170-byte DialogRecord structure. It identifies
the dialog containing the item you wish to modify. It is actually a
WindowPtr (a.k.a GrafPtr or cGrafPtr) and is normally obtained via
theItem identifies which item you wish to modify. Item numbers start with
1 and are in the order as located in the item list, normally defined by
a 'DITL' resource.
iType specifies the desired type for the item. The only valid use for this is
to enable or disable an item by ORing or masking bit 7 (after getting
its current value via GetDItem).
iHandle is a 4-byte value; a generic Handle (statText, editText, or
iconItem), ControlHandle (ctrlItem), PicHandle (picItem), or a
ProcPtr (userItem) As with iType, you will normally want to use
the same value as that obtained from a previous call to GetDItem.
iRect is the address of an 8-byte Rect structure. It identifies the item's
enclosing rectangle, in coordinates local to theDialog 's window. Don't
use this to move or re-size controls (see Notes).
Returns: none

Notes: SetDItem is most often used for setting up a custom display procedure for
user items. It can also be used to disable/enable items and to move or
re-size some items.
To Set Up a Custom Item Display Procedure: While alerts
automatically frame the default item, this is not done for dialogs. The
standard way to frame the OK button is to place a dummy item of type
userItem anywhere in the dialog, create a simple procedure to outline item
#1, and use SetDItem to install the address of that procedure as the item's
handle; e.g.,
SetRect( &r, theItem.left, theItem.top, theItem.right, theItem.bottom );
SetDItem( theDlg, 10, 0, MyItemProc, &r );
See ModalDialog for the layout of the custom item display procedure and
a complete example of this common operation.
To Disable an Item: A disabled item looks just like an enabled one; the
difference is that ModalDialog ignores clicks on disabled items.
Generally, you will disable all statText and other display-only items in the
'DITL' resource. However, you may wish to disable an editText item; e.g.:
short iType;
Handle iHandle;
Rect iRect;
GetDItem( theDlg, 3, &iType, &iHandle, &iRect);
SetDItem( theDlg, 3, (iType | itemDisable), iHandle, &iRect);
Even when disabled the user can tab to the item, click on the text and
change it, etc; you just won't be notified.
To disable a control: Use GetDItem to get iHandle and pass it to
HiliteControl(iHandle, 255). This dims the control title.
To Move or Resize an Item: You can change the size and position of any
editText, userItem, etc. This can be used to move an item off-screen or to
enlarge an editText box, etc. for example:
short iType;
Handle iHandle;
Rect iRect;
GetDItem( theDlg, 3, &iType, &iHandle, &iRect);
OffsetRect( &iRect, 1000, 0 ); /* move it off screen */
SetDItem( theDlg, 3, iType, iHandle, &iRect);
Moving editText items this way can cause unwanted behavior when the tab
key is pressed. A more convenient way to move an item off screen is to use
HideDItem and ShowDItem [128K ROMs].
To move/resize a control: Use GetDItem to get a ControlHandle and call