Next: The InformationDialog Widget
This dialog is used to inform the user of a possible mistake in the program or
with the interaction with the program.
A typical example might be when you select the quit button (or menu item) to
terminate the program - if this was selected mistakenly and there is no
warning prompt you have got problems!!
The dialog1.c program attaches a pop-up WarningDialog when the quit menu
option is selected (Fig 12).
If you now select OK the program terminates.
Cancel returns back to the program.
Fig. 12 dialog1.c output
How do we do this?
- All the warning Dialog contains is an XmString which is the prompt
to the user.
- For the Quit button we ask: ``Are you sure you want to quit?''.
- Set the xm_string variable accordingly.
- Set the XmNmessageString resource to the xm_string value.
- Create the WarningDialog widget with the XmCreateWarningDialog()
- Add callback functions to Ok, Cancel or Help buttons of
- In this case we only need to detect the Ok button. The resource
XmNokCallback therefore need a function attached. Other button presses
will be ignored.
- XtManage() the Dialog widget so that it is displayed.
- XtPopup() can be used to pop-up the widget also.