Common Desktop Environment: Application Builder User's Guide

Example: Writing Code for Messages

Once you have created a message as described in "To Create a Message Dialog Box ", you must determine when and how it should be displayed. Usually messages are displayed after a certain piece of logic has been executed. For example, if a user types digits in a text field that is designed to accept a name, you will want to post an error message informing the user that digits are not valid.

Message boxes in Motif can be displayed in one of two ways: modally or non-modally (equivalently, blocking or non-blocking). The App Builder code generator (dtcodegen) supplies two routines, corresponding to the two modes of display. They are found in dtb_utils.c and are named:

If you want to display a particular message modally, use dtb_show_modal_message(). If you want to display a particular message non-modally, use dtb_show_message().

One of the key differences in the way these two types of of messages are handled is in how the application determines which button was pressed by the user in the message dialog box. For non-modal messages callbacks are added to each button via the Connections Editor. When the user clicks a button the corresponding callback is called. Since modal dialogs are blocking, the button callbacks are not called. Instead, the value is returned by dtb_show_modal_message(), which indicates which button is pressed by the user.