Movatterモバイル変換


[0]ホーム

URL:


Function Reference


MsgBox

Displays a simple message box with optional timeout.

MsgBox ( flag, "title", "text" [, timeout = 0 [, hwnd]] )

Parameters

flagThe flag indicates the type of message box and the possible button combinations. See remarks.
titleThe title of the message box.
textThe text of the message box.
timeout[optional] Timeout in seconds. After the timeout has elapsed the message box will close automatically. The default is 0, which is no timeout.
hwnd[optional] The window handle to use as the parent for this dialog.

Return Value

Success:the ID of the button pressed.
Failure:$IDTIMEOUT (-1) if the message box timed out.


Button PressedReturn Value
OK$IDOK (1)
CANCEL$IDCANCEL (2)
ABORT$IDABORT (3)
RETRY$IDRETRY (4)
IGNORE$IDIGNORE (5)
YES$IDYES (6)
NO$IDNO (7)
TRY AGAIN$IDTRYAGAIN (10)
CONTINUE$IDCONTINUE (11)

Constants are defined in MsgBoxConstants.au3.

Remarks

The flag parameter can be a combination of the following values:

Constant NameDecimal flagButton-related resultHexadecimal flag
$MB_OK0OK button0x0
$MB_OKCANCEL1OK and Cancel0x1
$MB_ABORTRETRYIGNORE2Abort, Retry, and Ignore0x2
$MB_YESNOCANCEL3Yes, No, and Cancel0x3
$MB_YESNO4Yes and No0x4
$MB_RETRYCANCEL5Retry and Cancel0x5
$MB_CANCELTRYCONTINUE6Cancel, Try Again, Continue0x6
$MB_HELP16384Adds a Help button to the message box. When the user clicks the Help button or presses F1, the system sends a WM_HELP message to the owner.0x4000
Constant Namedecimal flagIcon-related Resulthexadecimal flag
$MB_ICONNONE0(No icon)0x0
$MB_ICONERROR16Stop-sign icon0x10
$MB_ICONQUESTION32Question-mark icon0x20
$MB_ICONWARNING48Exclamation-point icon0x30
$MB_ICONINFORMATION64Information-sign icon consisting of an 'i' in a circle0x40
Constant Namedecimal flagDefault-related Resulthexadecimal flag
$MB_DEFBUTTON10First button is default button0x0
$MB_DEFBUTTON2256Second button is default button0x100
$MB_DEFBUTTON3512Third button is default button0x200
$MB_DEFBUTTON4768Fourth button is default button0x300
Constant Namedecimal flagModality-related Resulthexadecimal flag
$MB_APPLMODAL0Application0x0
$MB_SYSTEMMODAL4096System modal (dialog has an icon)0x1000
$MB_TASKMODAL8192Task modal0x2000
Constant Namedecimal flagMiscellaneous-related Resulthexadecimal flag
0(nothing else special)0x0
$MB_DEFAULT_DESKTOP_ONLY131072MsgBox() shows on the desktop of the interactive window station.0x20000
$MB_RIGHT524288title and text are right-justified0x80000
$MB_RTLREADING1048576Displays message and caption text using right-to-left reading order on Hebrew and Arabic systems.0x100000
$MB_SETFOREGROUND65536The message box becomes the foreground window.0x10000
$MB_TOPMOST262144MsgBox() has top-most attribute set0x40000
$MB_SERVICE_NOTIFICATION2097152The function displays a message box on the current active desktop, even if there is no user logged on to the computer.0x200000

For example, to specify a SYSTEMMODAL box with the YES/NO buttons the flag value would be 4096+4 (or 4100) If using hexadecimal flags, that would be 0x1000+0x4 (or 0x1004).

A message box appears centered on screen and resizes according to the text it contains. However, the title could get truncated if the SYSTEMMODAL flag (4096) is used.

If "title" is equal toDefault keyword @ScriptName is used.

Special note; MsgBox does not support the use of the timeout parameter when the $MB_SERVICE_NOTIFICATION flag is used when calling MsgBox from a service. The message box window is not owned by the process calling MsgBox when $MB_SERVICE_NOTIFICATION is specified.

Constants are defined in MsgBoxConstants.au3.

Related

InputBox,SplashTextOn,ToolTip,TrayTip

Example

Example 1

#include<MsgBoxConstants.au3>MsgBox($MB_SYSTEMMODAL,"Title","This message box will timeout after 10 seconds or select the OK button.",10)

Example 2

#include<MsgBoxConstants.au3>Local$iTimeout=10; Display a message box with a nested variable in its text.MsgBox($MB_SYSTEMMODAL,"Title","This message box will timeout after "&$iTimeout&" seconds or select the OK button.",$iTimeout)

[8]ページ先頭

©2009-2025 Movatter.jp