Microsoft KB Archive/69602

= How to Use a Modeless Dialog Box in Macintosh QuickBASIC =

Article ID: 69602

Article Last Modified on 11/21/2006



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 &quot;Inside Macintosh&quot; 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 &quot;Microsoft QuickBASIC for Apple Macintosh: Language Reference&quot; manual.

Using Modeless Dialog Boxes
Modeless dialog boxes are loaded the same way as modal dialog boxes -- with the GetNewDialog routine. If the &quot;Visible&quot; property of the dialog is set via ResEdit, then GetNewDialog will also display the dialog box. The &quot;Visible&quot; 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 &quot;PQ&quot;, &A981, (pointer&)

where:

&quot;PQ&quot; is the type of ROM call.

&A981 is the trap address of the ROM routine &quot;DrawDialog&quot;.

(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 &quot;About...&quot; box, a default ' dialog box in all programs, as a modeless dialog box. ' Note that the dialog box must be made &quot;Visible&quot; through ' ResEdit for this to work correctly.

Trap% = &HA981    'Address of the ROM call (trap) for DrawDialog. DialogNum% = 128  'ID# of the &quot;About..&quot; 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 &quot;I&quot;       'Initialize the toolbox. ToolBox &quot;PQ&quot;, Trap%, (pointer&)   'Call the DrawDialog routine. PRINT &quot;Wait...&quot; FOR i = 1 to 2000: NEXT i DisposeDialog pointer&   'QuickBASIC library call to dispose the box. END

Additional query words: MQuickB

Keywords: KB69602

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.