MessageBox (Windows CE 5.0)

Windows CE 5.0
Send Feedback

This 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.

int MessageBox(
  HWND hWnd, 
  LPCTSTR lpText, 
  LPCTSTR lpCaption, 
  UINT uType
); 

Parameters

hWnd
[in] 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] Long pointer to a null-terminated string that contains the message to be displayed.
lpCaption
[in] Long pointer to a null-terminated string used for the dialog box title. If this parameter is NULL, the default title Error is used.
uType
[in] Specifies a set of bit flags that determine the contents and behavior of the dialog box. This parameter can be a combination of flags from the following groups of flags.

Specify one of the following flags to indicate the buttons contained in the message box.

ValueDescription
MB_ABORTRETRYIGNOREThe message box contains three push buttons: Abort, Retry, and Ignore.
MB_OKThe message box contains one push button: OK. This is the default.
MB_OKCANCELThe message box contains two push buttons: OK and Cancel.
MB_RETRYCANCELThe message box contains two push buttons: Retry and Cancel.
MB_YESNOThe message box contains two push buttons: Yes and No.
MB_YESNOCANCELThe message box contains three push buttons: Yes, No, and Cancel.

Specify one of the following flags to display an icon in the message box.

ValueDescription
MB_ICONEXCLAMATION, MB_ICONWARNINGAn exclamation-point icon appears in the message box.
MB_ICONINFORMATION, MB_ICONASTERISKAn icon consisting of a lowercase letter i in a circle appears in the message box.
MB_ICONQUESTIONA question-mark icon appears in the message box.
MB_ICONSTOP, MB_ICONERROR, MB_ICONHANDA stop-sign icon appears in the message box.

Specify one of the following flags to indicate the default button.

ValueDescription
MB_DEFBUTTON1The first button is the default button.

MB_DEFBUTTON1 is the default unless MB_DEFBUTTON2, MB_DEFBUTTON3, or MB_DEFBUTTON4 is specified.

MB_DEFBUTTON2The second button is the default button.
MB_DEFBUTTON3The third button is the default button.
MB_DEFBUTTON4The fourth button is the default button.

The following flag is the default modality of the dialog box.

ValueDescription
MB_APPLMODALThe user must respond to the message box before continuing work in the window identified by the hWnd parameter. However, the user can move to the windows of other threads and work in those windows.

Depending on the hierarchy of windows in the application, the user may be able to move to other windows within the thread. All child windows of the parent of the message box are automatically disabled, but popup windows are not.

In addition, you can specify the following flags.

ValueDescription
MB_SETFOREGROUNDThe message box becomes the foreground window. Internally, the system calls the SetForegroundWindow function for the message box.
MB_TOPMOSTThe message box is created with the WS_EX_TOPMOST window style.
MB_RTLREADINGThe message box displays message and caption text using right-to-left reading order on Hebrew and Arabic systems.

Return Values

Zero indicates that there is not enough memory to create the message box.

Upon success, one of the values described in the following table is returned.

ValueDescription
IDABORTAbort button was selected.
IDCANCELCancel button or the close button on the title bar was selected.
IDIGNOREIgnore button was selected.
IDNONo button was selected.
IDOKOK button was selected.
IDRETRYRetry button was selected.
IDYESYes button was selected.

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.

Remarks

If you create a message box while a dialog box is present, use the handle of 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

OS Versions: Windows CE 1.0 and later.
Header: Windows.h.
Link Library: Msgbox.lib.

See Also

MessageBeep | SetForegroundWindow | Dialog Boxes Functions


Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.


Show: