Incode Systems Home Page Incode Systems, Inc.


MsgBox



(Windows 95 or higher command line utility)
(02-05-2002 5:17pm MSGBOX.EXE)

MsgBox displays a message and sets an errorlevel indicating the user response.

Usage: [-option1 -option2] "This is the message"

ERRORLEVEL set is:

ID_OK = 1; OK button was pressed
ID_CANCEL = 2; Cancel button was pressed (or box closed)
ID_ABORT = 3; Abort button was pressed
ID_RETRY = 4; Retry button was pressed
ID_IGNORE = 5; Ignore button was pressed
ID_YES = 6; Yes button was pressed
ID_NO = 7; No button was pressed

When testing for ERRORLEVEL in a batch, check in the reverse order:

MSGBOX -YesNoCancel "Press Yes, No, or Cancel" IF ERRORLEVEL 8 GOTO UNKNOWN
IF ERRORLEVEL 7 GOTO NOBTN
IF ERRORLEVEL 6 GOTO YESBTN
IF ERRORLEVEL 5 GOTO IGNOREBTN
IF ERRORLEVEL 4 GOTO RETRYBTN
IF ERRORLEVEL 3 GOTO ABORTBTN
IF ERRORLEVEL 2 GOTO CANCELBTN
IF ERRORLEVEL 1 GOTO OKBTN
GOTO UNKNOWN

Usage: [-option1 -option2] "This is the message"

Options:

AbortRetryIgnore
Buttons are: Abort, Retry, and Ignore

ApplModal
Application Modal. Use FgWin (Foreground Window) option with this. The application with the focus at the time MsgBox runs are not accessible until MsgBox is closed.

Default_Desktop_Only
If the current desktop is not the default desktop, MsgBox is not displayed.

DefButton1
The first button is the default button (default).

DefButton2
The second button is the default button (default).

DefButton3
The third button is the default button (default).

DefButton4
The fourth button is the default button (default).

FgWin
The foreground window is used with MsgBox. This may be used with the ApplModal option.

Help
Adds a help button.

IconError
A stop-sign icon is displayed in the message box.

IconExclamation
An exclamation-point icon is displayed in the message box.

IconHand
A stop-sign icon is displayed in the message box.

IconInformation
An information icon is displayed in the message box.

IconQuestion
An question-mark icon is displayed in the message box.

IconStop
A stop-sign icon is displayed in the message box.

IconWarning
An exclamation-point icon is displayed in the message box.

OK
Buttons is: OK (default)

OKCancel
Buttons are: OK and Cancel

RetryCancel
Buttons are: Retry and Cancel

Right
Message is right-justified

RTLReading
Message is displayed right-to-left reading order

SetForeground
MsgBox becomes the foreground window

SystemModal
All applications are suspended until MsgBox is closed

TaskModal
Application Modal. Use FgWin (Foreground Window) option with this. The application with the focus at the time MsgBox runs are not accessible until MsgBox is closed.

YesNo
Buttons are: Yes and No

YesNoCancel
Buttons are: Yes, No, and Cancel

The title of the MsgBox may be set with an option that start with a T and is immediately followed by the title. Spaces are replaced with underscores. Here is an example:

-TThe_Title


Examples:

MsgBox -YesNo -TMy_MsgBox "Here is the message"


START NOTEPAD
MsgBox -ApplModal -FgWin -TMy_MsgBox "Close this before working in NotePad"


Batch file programming tips: Different versions of Windows process batch files in different ways. Normally, when DOS programs or Windows commandline programs are run from a batch, the batch waits for the program to end before continuing with the next line in the batch. Windows programs are normally launched and the batch continues with the next line. The START command may be used to force the desired behavior. If your batch is pausing when a Windows program is launched, and you want the batch to continue, use START to launch the program (as shown in the example above). On the other hand, if the batch is continuing when you want it to wait for a program to complete, use START with the /W option (example: START /W NOTEPAD).

If you use START with MsgBox to cause the batch to continue, an command prompt window will open in addition to the MsgBox. MsgBoxA (MsgBox Asynchronous) may be used to avoid the command prompt window when you want the MsgBox to be displayed while the batch file continues. MsgBoxA does not return ERRORLEVEL, however, so it is only useful for displaying messages.