Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Macintosh Toolbox Essentials /
Chapter 6 - Dialog Manager / Dialog Manager Reference
Application-Defined Routines /


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 it MyItem:

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 procedure ShowWindow to display the dialog box.

Before you display the dialog box, use the SetDialogItem procedure to install this procedure in the dialog record. Before using SetDialogItem, you must first use the GetDialogItem procedure to obtain a handle to an item of type userItem.

If you enable the application-defined item that you draw with this procedure, the ModalDialog procedure and the DialogSelect 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 use ModalDialog, your event filter function must handle events inside the item; if you use DialogSelect, your application must handle events inside the item before handing events to DialogSelect.

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 of GetDialogItem and SetDialogItem to install this draw procedure in a dialog
record. The ShowWindow procedure is described in the chapter "Window Manager"
in this book.


Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 JUL 1996