dialog = XmCreateMessageBox (shell, "MessageDialog", NULL, 0);
XtAddCallback (dialog, XmNokCallback, callback_func, NULL);
XtAddCallback (dialog, XmNcancelCallback, callback_func, NULL);
XtAddCallback (dialog, XmNhelpCallback, help_func, NULL);
8.6 Positioning Dialogs
In all of the dialog examples that you have seen so far, the toolkit has handled the positioning of the dialog. For
dialogs that use the DialogShell widget with a subclass of BulletinBoard as the immediate child, the
XmNdefaultPosition resource controls this behavior. If the resource is True, the dialog is centered relative to
the parent of the DialogShell and placed on top of the parent. If the resource is set to False, the application is
responsible for positioning the dialog. It is easy to position a dialog using the XmNmapCallback resource that is
supported by all of the Motif manager widgets, as shown in the source code
/* map_dlg.c −− Use the XmNmapCallback to automatically position
* a dialog on the screen. Each time the dialog is displayed, it
* is mapped down and to the right by 200 pixels in each direction.
*/
#include <Xm/MessageB.h>
#include <Xm/PushB.h>
/* main() −−create a pushbutton whose callback pops up a dialog box */
main(argc, argv)
int argc;
char *argv[];
{
Widget toplevel, button;
XtAppContext app;
void pushed();
toplevel = XtVaAppInitialize (&app, "Demos",
NULL, 0, &argc, argv, NULL, NULL);
button = XtVaCreateManagedWidget ("Push Me",
xmPushButtonWidgetClass, toplevel,
NULL);
XtAddCallback (button, ...