Skip to content

MessageBox

Constants of the MessageBox Dialog Window

This section contains return codes of the MessageBox() function. If a message window has a Cancel button, the function returns IDCANCEL, in case if the ESC key or the Cancel button is pressed. If there is no Cancel button in the message window, the pressing of ESC does not give any effect.

ConstantValueDescription
IDOK1“OK” button has been pressed
IDCANCEL2“Cancel” button has been pressed
IDABORT3“Abort” button has been pressed
IDRETRY4“Retry” button has been pressed
IDIGNORE5“Ignore” button has been pressed
IDYES6“Yes” button has been pressed
IDNO7“No” button has been pressed
IDTRYAGAIN10“Try Again” button has been pressed
IDCONTINUE11“Continue” button has been pressed

The main flags of the MessageBox() function define contents and behavior of the dialog window. This value can be a combination of the following flag groups:

ConstantValueDescription
MB_OK0x00000000Message window contains only one button: OK. Default
MB_OKCANCEL0x00000001Message window contains two buttons: OK and Cancel
MB_ABORTRETRYIGNORE0x00000002Message window contains three buttons: Abort, Retry and Ignore
MB_YESNOCANCEL0x00000003Message window contains three buttons: Yes, No and Cancel
MB_YESNO0x00000004Message window contains two buttons: Yes and No
MB_RETRYCANCEL0x00000005Message window contains two buttons: Retry and Cancel
MB_CANCELTRYCONTINUE0x00000006Message window contains three buttons: Cancel, Try Again, Continue

To display an icon in the message window it is necessary to specify additional flags:

ConstantValueDescription
MB_ICONSTOP,

MB_ICONERROR,

MB_ICONHAND | 0x00000010 | The STOP sign icon | | MB_ICONQUESTION | 0x00000020 | The question sign icon | | MB_ICONEXCLAMATION,

MB_ICONWARNING | 0x00000030 | The exclamation/warning sign icon | | MB_ICONINFORMATION,

MB_ICONASTERISK | 0x00000040 | The encircled i sign |

Default buttons are defined by the following flags:

ConstantValueDescription
MB_DEFBUTTON10x00000000The first button MB_DEFBUTTON1 - is default, if the other buttons MB_DEFBUTTON2, MB_DEFBUTTON3, or MB_DEFBUTTON4 are not specified
MB_DEFBUTTON20x00000100The second button is default
MB_DEFBUTTON30x00000200The third button is default
MB_DEFBUTTON40x00000300The fourth button is default
Last updated on