Message Boxes

A message box is a special kind of modal dialog box that an application uses to display messages and prompt for simple input. A message box typically contains a text message and one or more predefined buttons. You do not need to provide a dialog box template or dialog box procedure for a message box. Windows creates the template based on the text and buttons you specify and supplies its own dialog box procedure.

    

Message box

Use the MessageBox function to create a message box, specifying the text and the number and types of buttons to display. Because Windows CE controls the creation and management of the message box, you do not provide a dialog box template and dialog box procedure. Windows CE creates its own template based on the text and buttons specified for the message box and supplies its own dialog box procedure.

Note As with dialog boxes, sometimes it is necessary for a message box to appear on top of all other windows. In particular, under low memory conditions, the System Out of Memory Dialog Box will send a WM_CLOSE message to an application. If the application is not in the foreground, any message box it puts up will be hidden behind the current foreground window unless you create the message box with the MB_SETFOREGROUND style. Because putting the message box in the foreground will not bring the application's main window forward, put any information in the message box that the user may need to decide what action to take.

The MessageBeep function, generally used with message boxes, plays a waveform sound. The waveform sound for each sound type is identified by an entry in the sounds section of the registry.

Message box styles supported by Windows CE are described in the following table.

Message box style Description
Buttons  
MB_ABORTRETRYIGNORE The message box contains three buttons: Abort, Retry, and Ignore.
MB_OK The message box contains one button: OK.
MB_OKCANCEL The message box contains two buttons: OK and Cancel.
MB_RETRYCANCEL The message box contains two buttons: Retry and Cancel.
MB_YESNO The message box contains two buttons: Yes and No.
MB_YESNOCANCEL The message box contains three buttons: Yes, No, and Cancel.
MB_DEFBUTTON1 The first button is the default button. Note that the first button is always the default unless you specify MB_DEFBUTTON2.
MB_DEFBUTTON2 The second button is the default button.
MB_DEFBUTTON3 The third button is the default button.
Icons  
MB_ICONASTERISK
MB_ICONINFORMATION
An icon consisting of a lowercase letter i in a circle appears in the message box.
MB_ICONEXCLAMATION
MB_ICONWARNING
An exclamation-point icon appears in the message box.
MB_ICONERROR
MB_ICONHAND
MB_ICONSTOP
A stop-sign icon appears in the message box.
MB_ICONQUESTION A question-mark icon appears in the message box.
Window styles  
MB_APPLMODAL The 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 applications 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 application. All child windows of the message box's parent window are automatically disabled, but pop-up windows are not.

MB_APPLMODAL is the default value. Windows CE does not support either MB_SYSTEMMODAL or MB_TASKMODAL.

MB_SETFOREGROUND The message box becomes the foreground window.
MB_TOPMOST The message box is created with the WS_EX_TOPMOST window style.