How to Use a Modeless Dialog Box in Macintosh QuickBASIC (69602)






This article was previously published under Q69602

SUMMARY

Apple's Macintosh Dialog Manager supports dialog boxes and alert messages. The MBLC library routines provided in Microsoft QuickBASIC let you call certain routines from the Dialog Manager. However, QuickBASIC's MBLC routines only support modal dialog boxes; that is, dialog boxes that require the user to respond. The following article illustrates how a program can display a modeless dialog box that does not require a user response.

The following information applies to Microsoft QuickBASIC versions 1.00, 1.00a, and 1.00b for the Apple Macintosh.

MORE INFORMATION

A dialog box is a temporary window that displays information. There are three basic types of dialog boxes: modal, alert, and modeless. Modal and alert dialog boxes suspend program execution until the user responds. A modeless dialog box does not require user response, and usually displays temporary information while another process is performed. For more information about dialog boxes, see "Inside Macintosh" Volume 1, by Apple Computer Inc. (published by Addison-Wesley).

Using Modal and Alert Dialog Boxes

You can create a dialog box using ResEdit, and add the dialog box to your program. To access a normal modal dialog box, you execute GetNewDialog (an MBLC routine in QuickBASIC) to read the dialog box out of a file's resource fork into memory. To display the dialog box on the screen, invoke ModalDialog (an MBLC routine in QuickBASIC). ModalDialog waits for a user response before continuing. For more information on creating and using modal dialog boxes, see pages 439-442 of the "Microsoft QuickBASIC for Apple Macintosh: Language Reference" manual.

Using Modeless Dialog Boxes

Modeless dialog boxes are loaded the same way as modal dialog boxes -- with the GetNewDialog routine. If the "Visible" property of the dialog is set via ResEdit, then GetNewDialog will also display the dialog box. The "Visible" property must be set for modeless dialog boxes. Note, however, that any PICT or ICON resource will not be displayed because only the resource id# is loaded by GetNewDialog, not the resource itself. To display all the resources contained in a dialog box, you must draw the dialog box, which is normally done by calling ModalDialog. However, to display the dialog box as modeless, you must invoke the DrawDialog toolbox ROM routine instead. DrawDialog is not a part of QuickBASIC's library routines. Therefore, you must invoke DrawDialog through QuickBASIC's ToolBox statement, as follows

ToolBox "PQ", &A981, (pointer&)

where:

"PQ" is the type of ROM call.
&A981 is the trap address of the ROM routine "DrawDialog".
(pointer&) is a pointer to the dialog information, set by the
GetNewDialog routine and passed by value ().

The following program demonstrates how QuickBASIC's ToolBox statement can invoke DrawDialog to display a modeless dialog box:

Program Example

'  This program will display the "About..." box, a default
'  dialog box in all programs, as a modeless dialog box.
'  Note that the dialog box must be made "Visible" through
'  ResEdit for this to work correctly.

Trap% = &HA981     'Address of the ROM call (trap) for DrawDialog.
DialogNum% = 128   'ID# of the "About.." dialog box.
pointer& = 0       'Initialize variables used in the ToolBox calls.
ref% = 0
CLS
ref% = SYSTEM(7)   'Get the reference number for the resource fork
                   'of the currently running program (compiled or
                   'interpreted.)
GetNewDialog ref%, DialogNum%, pointer&   'QuickBASIC library call.
ToolBox "I"        'Initialize the toolbox.
ToolBox "PQ", Trap%, (pointer&)    'Call the DrawDialog routine.
PRINT "Wait..."
FOR i = 1 to 2000: NEXT i
DisposeDialog pointer&    'QuickBASIC library call to dispose the box.
END
				

Modification Type: Minor Last Reviewed: 1/9/2003
Keywords: KB69602