7. Display a message box
[<<<] [>>>]
i = nt::MsgBox("Text","Caption" [,"buttons","style",defbutton])
This function displays a Windows message box on the screen and waits for the user to press
one of the buttons of the message box. The function should get two mandatory and three
optional arguments.
The arguments:
- "Text" the first argument to the function is the text that appears on the text box.
- "Caption" the second argument to the function is the caption of the message
box. This text appears in the top of the box.
- "buttons" This optional string specifies what buttons to diplay on the message box. If this
argument is missing a single OK button will appear on the box. The valid strings for this argument
are
- "ARI" Abort/Retry/Ignore
- "OK" OK
- "O" OK
- "OC" OK/Cancel
- "RC" Retry/Cancel
- "YN" Yes/No
- "YNC" Yes/No/Cancel
You can also write the string in a long form for better readability:
- "AbortRetryIgnore"
- "Ok"
- "OkCancel"
- "RetryCancel"
- "YesNo"
- "YesNoCancel"
- "style" this optional argument specifies what type of icon should appear on the message box
left to the text. There are four icons available:
- "Exclamation"
- "Ex"
- "Warning"
- "W" An exclamation-point icon appears in the message box.
- "Information"
- "Info"
- "I"
- "Asterix"
- "A"
- "*" An icon consisting of a lowercase letter i in a circle appears in the message box.
- "Question"
- "Q"
- "?" A question-mark icon appears in the message box.
- "Stop"
- "S"
- "Error"
- "E"
- "Hand"
- "H" A stop-sign icon appears in the message box.
If this argument is missing or undef no icon appears left to the text.
- defbutton should be an integer value between 1 to 4, or at most the number of the
buttons on the actual message box. This argument specifies , which button is the default
button on the form. The default button is selected as default and in case the user pressed
the Enter key instead of clickong on one of the buttons the default button is pressed.
The return value of the function is a one character string containing one of the characters
A, C, I, N, O, R, Y for the pressed buttons respectively: Abort, Cancel, Ignore, No, OK, Retry, Yes.
The parameters "buttons" and "style" are not case sensitive. The return value is uppercase
character.
The following example tests all the possible message boxes:
import nt.bas
nt::MsgBox """This program test the various text boxes.
In the coming message boxes press the various keys as requested by the text
and check on the console window that the program reported the correct
button you pressed. (Only initials are printed.)
""","Initial MsgBox"
splita " |ARI|O|RC|YN|YNC" BY "|" TO buttons
splita " |W|I|Q|S" BY "|" TO marks
for j=lbound(marks) to ubound(marks)
for i=lbound(buttons) to ubound(buttons)
for d=1 to len(buttons[i])
print i," ",buttons[i]," ",j," ",marks[j]," ",d,"\n"
R = nt::MsgBox(buttons[i],marks[j],buttons[i],marks[j],d)
print R
print
next d
next i
next j
[<<<] [>>>]