Util.MessageBox() Method

Interface to Win32 MessageBox() function. See the Win32 documentation.

Syntax

Util.MessageBox(Message, [Options], [title])

The method syntax has these parts:

Part Description
Message (String) The text of the message to display in the alert box.
Options (MessageBoxOptions) One or more options (added together) to control icon, button set, and modality. See table below. (default = mbOkOnly,no icon)
title (String) Text to appear in the title bar of the alert box (default = "DriverHelper.Util Object")
Return (MessageBoxAnswers) Varies depending on the buttons displayed.

Remarks

Provides Win32 MessageBox() functionality for scripting languages that do not have this capability (e.g., JScript). The Options parameter consists of one or more MessageBoxOption values added together. For example, to display a Yes/No confirmation alert with a question mark icon
ans = Util.MessageBox("Are you happy?", _
    (mbQuestion + mbYesNo), "Answer Truthfully"
ans will contain vbYes or vbNo (one of the MessageBoxAnswer constants).

Will raise an error if the console script was aborted prior to displaying the message box. This is mostly useful when called from components used by a script.

Symbolic Constants

The (symbolic) values for MessageBoxAnswers are:

Constant Value Description
mbAbort 3 Return value: the Abort button was clicked.
mbCancel 2 Return value: the Cancel button was clicked.
mbIgnore 5 Return value: the Cancel button was clicked.
mbNo 7 Return value: the No button was clicked.
mbOK 1 Return value: the OK button was clicked.
mbRetry 4 Return value: the Retry button was clicked.
mbYes 6 Return value: the Yes button was clicked.

The (symbolic) values for MessageBoxOptions are:

Constant Value Description
mbAbortRetryIgnore 2 The message box contains three push buttons: Abort, Retry, and Ignore.
mbApplicationModal 0 Application modal; the user must respond to the message box before continuing work in the current application. The default unless mbSystemModal is specified.
mbDefaultDesktopOnly 131072 Windows NT/2000/XP: System will display the message box only on the default desktop. If the current input desktop is not the default desktop, MessageBox does not return until the user switches to the default desktop.
mbDefButton1 0 The first button is the default button. The first button is the default button. The default unless mbDefButton2 or mbDefButton3 is specified.
mbDefButton2 256 The second button is the default button.
mbDefButton3 512 The third button is the default button.
mbIconExclamation 48 An exclamation-point icon appears in the message box.
mbIconInformation 64 An icon consisting of a lowercase letter i in a circle appears in the message box.
mbIconQuestion 32 A question-mark icon appears in the message box.
mbIconStop 16 A stop-sign icon appears in the message box.
mbNoFocus 32768 Do not shift the focus to the message box when first displayed.
mbOKCancel 1 The message box contains two push buttons: OK and Cancel.
mbOKOnly 0 The message box contains one push button: OK. This is the default.
mbRetryCancel 5 The message box contains two push buttons: Retry and Cancel.
mbSetForeground 65536 Force the message box to the foreground when first displayed. This is not the same as the "topmost" style that mbSystemModal produces.
mbSystemModal 4096 Same as mbApplicationModel except that the message box has "topmost window" style. Use system-modal message boxes to notify the user of serious, potentially damaging errors that require immediate attention (for example, running out of memory).
mbYesNo 4 The message box contains two push buttons: Yes and No.
mbYesNoCancel 3 The message box contains three push buttons: Yes, No, and Cancel.