Important: The information in this document is obsolete and should not be used for new development.
MyItem
To draw your own application-defined item in a dialog box, provide a draw procedure that takes two parameters: a window pointer to the dialog box and an item number from the dialog box's item list resource. For example, this is how you should declare the procedure if you were to name itMyItem
:
PROCEDURE MyItem (theWindow: WindowPtr; itemNo: Integer);
theWindow
- A pointer to the dialog record for the dialog box containing an application-defined item. If your procedure can draw in more than
one dialog box, this parameter tells your procedure which one to
draw in.itemNo
- A number corresponding to the position of an item in the item list resource for the specified dialog box. If your procedure draws more
than one item, this parameter tells your procedure which one to draw.DESCRIPTION
The Dialog Manager calls your procedure to draw an application-defined item at the time you display the specified dialog box. When calling your draw procedure, the Dialog Manager sets the current port to the dialog box's graphics port. Normally, you create an invisible dialog box and then use the Window Manager procedureShowWindow
to display the dialog box.Before you display the dialog box, use the
SetDialogItem
procedure to install this procedure in the dialog record. Before usingSetDialogItem
, you must first use theGetDialogItem
procedure to obtain a handle to an item of typeuserItem
.If you enable the application-defined item that you draw with this procedure, the
ModalDialog
procedure and theDialogSelect
function return the item's number when the user clicks that item. If your application needs to respond to a user action more complex than this (for example, if your application needs to measure how long the user holds down the mouse or how far the user drags the cursor), your application must track the cursor itself. If you useModalDialog
, your event filter function must handle events inside the item; if you useDialogSelect
, your application must handle events inside the item before handing events toDialogSelect
.SEE ALSO
Listing 6-17 on page 6-59 illustrates a procedure that draws a bold outline around
a button of any size and shape; Listing 6-16 on page 6-58 shows the use ofGetDialogItem
andSetDialogItem
to install this draw procedure in a dialog
record. TheShowWindow
procedure is described in the chapter "Window Manager"
in this book.