Message Boxes

By convention, message boxes are used to inform the user of an event, and to carry out a dialog with the user in the following circumstances:

  • Where the information to be conveyed to the user is simple and limited to no more than a few lines of text

  • Where the input to be gained from the user is limited to a single decision from a limited list of mutually exclusive options.

    The type of decision available to the user from a message box is also limited to simple choices such as "Yes/No", "OK/Cancel", or "Yes/No/Help". Since the buttons displayed in the message box are push buttons, selecting any button will result in the removal of the message box from the screen and immediate action on the part of the application. An exception to this rule is the "Help" button, which should result in the message box being left on the screen, and the simultaneous display of a window containing help information. This help window should be a child of the message box, so that it is dismissed when the message box is closed, and the input focus should return to the message box when the help window is dismissed.

    A message box is created and processed using the WinMessageBox() function as follows:

    rc = WinMessageBox(hDesktop,                 /* Desktop is parent     */
                       hwnd,                     /* Curr. window is owner */
                       szMessageText,            /* Message text          */
                       "Warning",                /* Title of message box  */
                       0,                        /* No message box ident. */
                       MB_YESNO |                /* Yes/No choices        */
                       MB_DEFBUTTON1 |           /* Yes is default choice */
                       MB_CUAWARNING);           /* Warning style         */
    

    Message boxes may be of three types:

  • Notification message boxes inform the user of a system event that requires his/her attention, but does not signify an error or potential error condition. Such message boxes are created with the message style MB_CUANOTIFICATION.

  • Warning message boxes inform the user of a potential error condition that may affect the integrity of the application or its data; for example, the user may try to exit the application without saving the latest set of changes to a data object. Such message boxes are created with the message style MB_CUAWARNING.

  • Critical message boxes inform the user of an error condition that requires his/her immediate attention; for example, a diskette may be unreadable. Such message boxes are created with the message style MB_CUACRITICAL.

    These message box styles may be combined with other style identifiers that determine the buttons to be displayed in the message box, the default action and the modality of the message box (that is, system- or application-modal). These identifiers are described, along with the WinMessageBox() function, in the IBM OS/2 Version 2.0 Presentation Manager Reference.

    A message box should always be created with a title; while Presentation Manager provides a default message title if a null title string is specified in the WinMessageBox() function, the use of this feature is not recommended. A message box title should identify the object or action from which the message originated; for example, a message originating from a "Parts List" object would have the title "Parts List", whereas a message occurring as a result of an incorrectly completed dialog during an "Open File" action would have a title of "Open File".

    A message box is created as an optimized window, and by default is neither moveable nor sizable. However, the situation may arise where the message is related to some information displayed in a window, and the decision to be made by the user is dependent upon the nature and context of that information. The user must therefore be able to view the information in order to make the decision required by the message box, and the information may be hidden by the message box itself. To avoid this situation, a message box may be specified with the style identifier MB_MOVEABLE, which allows the message box to be moved (although not sized) by clicking the mouse on its title in a similar fashion to that used for a standard window.


    [Back: Use of Control Windows]
    [Next: Maintaining User Responsiveness]