Export (0) Print
Expand All
3 out of 9 rated this helpful - Rate this topic

MessageBoxEx function

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 WINAPI MessageBoxEx(
  _In_opt_  HWND hWnd,
  _In_opt_  LPCTSTR lpText,
  _In_opt_  LPCTSTR lpCaption,
  _In_      UINT uType,
  _In_      WORD wLanguageId
);

Parameters

hWnd [in, optional]

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.

lpText [in, optional]

Type: LPCTSTR

The message to be displayed.

lpCaption [in, optional]

Type: LPCTSTR

The dialog box title. If this parameter is NULL, the default title Error is used.

uType [in]

Type: UINT

The contents and behavior of the dialog box. For information on the supported flags, see MessageBox.

wLanguageId [in]

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 has no effect.

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/valueDescription
IDABORT
3

The Abort button was selected.

IDCANCEL
2

The Cancel button was selected.

IDCONTINUE
11

The Continue button was selected.

IDIGNORE
5

The Ignore button was selected.

IDNO
7

The No button was selected.

IDOK
1

The OK button was selected.

IDRETRY
4

The Retry button was selected.

IDTRYAGAIN
10

The Try Again button was selected.

IDYES
6

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.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

Unicode and ANSI names

MessageBoxExW (Unicode) and MessageBoxExA (ANSI)

See also

Reference
MessageBox
MessageBoxIndirect
SetForegroundWindow
Conceptual
Dialog Boxes
Other Resources
MAKELANGID
MessageBeep

 

 

Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback

Community Additions

ADD
Show:
© 2014 Microsoft. All rights reserved.