Partager via


Message Boxes

A message box is a special kind of modal dialog box that an application uses to display messages and prompt for input. A message box typically contains a text message and one or more predefined buttons. The following screen shot shows a message box.

To create a message box, call the MessageBox function and specify the text and the number and types of buttons to display; because Windows CE controls the message box creation and management, you do not need to 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.

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 sends a WM_CLOSE message to an application. If the application is not in the foreground, any message box it brings up is 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 a user might need in order 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.

The following code example shows how to use the MessageBeep function.

MessageBeep(MB_ICONQUESTION);

For a list of message box styles supported by Windows CE, see Window and Control Styles.

Last updated on Wednesday, April 13, 2005

© 2005 Microsoft Corporation. All rights reserved.