Valid on Windows and Windows CE
The MessageBox or MsgBox function displays a message box window. The message box contains a message, a title, and any combination of the predefined buttons described by the style parameter.
Instead of MessageBox, you can use MsgBox to call the function.
Function format:
MessageBox(message as String, title as String, style as Integer) as Integer
MessageBox(message as String, title as String) as Integer
MessageBox(message as String, style as Integer) as Integer
MessageBox(message as String) as Integer
Identifies the string containing the message that is to be displayed.
Identifies an optional string containing the message box title.
Default: DMS
Identifies an optional integer specifying the contents and behavior of the message box. The style parameter can be any of the following predefined constants:
Adds box with button OK (Default)
Adds box with buttons OK and Cancel
Adds box with buttons Yes and No
Adds box with buttons Retry and Cancel
Adds box with buttons Yes, No, and Cancel
Adds box with buttons Abort, Retry, and Ignore
Constants for MessageBox Modality
By default, the user must respond to the message box before continuing work in the current window; however, the user can move to, and work in, windows of other applications.
All applications are suspended until the user responds to the message box. System modal message boxes are used to notify the user of serious, potentially damaging errors that require immediate attention.
Constants for MessageBox Icons
The default is as follows: No icon is shown.
Adds an exclamation point icon appears in the message box.
Adds an icon consisting of an "i" in a circle appears in the message box.
Adds a question-mark icon in the message box.
Adds a stop sign icon (white "X" in a red circle) appears in the message box.
Constants for MessageBox Default Buttons
The default is as follows. The first button is the default.
Makes the second button default.
Makes the third button default.
Other Constants
Sets the message box as the foreground window. If this is not coded, the current foreground window remains in the foreground.
You can combine each constant of one group with any constant of another group. For example, to display a message box with Abort, Retry, and Ignore (default) buttons, and a stop sign icon, and you want to suspend all applications until the user responds, code using the following style:
MB_ABORTRETRYIGNORE + MB_DEFBUTTON3 + MB_ICONSTOP + MB_SYSTEMMODAL
If the style parameter is omitted, MB_OK is assumed and the message box contains only the OK button.
If there is not enough memory to create the message box, the return value of the function is zero. Otherwise, it is one of the following button values returned by the message box:
Value 1; the OK button was clicked.
Value 2; the Cancel button (or keyboard Esc key). was clicked.
Value 3; the Abort button was clicked.
Value 4; the Retry button was clicked.
Value 5; the Ignore button was clicked.
Value 6; the Yes button was clicked.
Value 7; the No button was clicked.
Example:
This example checks with the user for creating a backup copy of the config.sys file, and creates the backup, if required.
Dim Src,Dst as string
Dim Question as string
Question="Do you want to make a backup of your config.sys?"
if MessageBox(Question,MB_YESNO)=IDYES then
Src="C:\CONFIG.SYS"
Dst="C:\CONFIG.BAK"
if CopyFile(Src,Dst,TRUE) then MessageBox("CONFIG.BAK created.")
end if
|
Copyright © 2014 CA Technologies.
All rights reserved.
|
|