MessageBoxExA function (winuser.h)
Creates, displays, and operates a message box. The message box contains an application-defined message and title, plus any combination of predefined icons and push buttons. The buttons are in the language of the system user interface.
Currently MessageBoxEx and MessageBox work the same way.
Syntax
int MessageBoxExA(
[in, optional] HWND hWnd,
[in, optional] LPCSTR lpText,
[in, optional] LPCSTR lpCaption,
[in] UINT uType,
[in] WORD wLanguageId
);
Parameters
[in, optional] hWnd
Type: HWND
A handle to the owner window of the message box to be created. If this parameter is NULL, the message box has no owner window.
[in, optional] lpText
Type: LPCTSTR
The message to be displayed.
[in, optional] lpCaption
Type: LPCTSTR
The dialog box title. If this parameter is NULL, the default title Error is used.
[in] uType
Type: UINT
The contents and behavior of the dialog box. For information on the supported flags, see MessageBox.
[in] wLanguageId
Type: WORD
The language for the text displayed in the message box button(s). Specifying a value of zero (0) indicates to display the button text in the default system language. If this parameter is MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL)
, the current language associated with the calling thread is used.
To specify a language other than the current language, use the MAKELANGID macro to create this parameter. For more information, see MAKELANGID.
Return value
Type: int
If a message box has a Cancel button, the function returns the IDCANCEL value if either the ESC key is pressed or the Cancel button is selected. If the message box has no Cancel button, pressing ESC will no effect - unless an MB_OK button is present. If an MB_OK button is displayed and the user presses ESC, the return value will be IDOK.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
If the function succeeds, the return value is one of the following menu-item values.
Return code/value | Description |
---|---|
|
The Abort button was selected. |
|
The Cancel button was selected. |
|
The Continue button was selected. |
|
The Ignore button was selected. |
|
The No button was selected. |
|
The OK button was selected. |
|
The Retry button was selected. |
|
The Try Again button was selected. |
|
The Yes button was selected. |
Remarks
When you use a system-modal message box to indicate that the system is low on memory, the strings pointed to by the lpText and lpCaption parameters should not be taken from a resource file because an attempt to load the resource may fail.
If you create a message box while a dialog box is present, use a handle to the dialog box as the hWnd parameter. The hWnd parameter should not identify a child window, such as a control in a dialog box.
Note
The winuser.h header defines MessageBoxEx as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | winuser.h (include Windows.h) |
Library | User32.lib |
DLL | User32.dll |
See also
Conceptual
Other Resources
Reference