Path: utzoo!attcan!utgpu!news-server.csri.toronto.edu!rutgers!usc!jarthur!uunet!mstan!jordan From: jordan@Morgan.COM (Jordan Hayes) Newsgroups: comp.windows.x Subject: Re: A yes/no dialog (or synchronous operations) Message-ID: <2245@s6.Morgan.COM> Date: 21 Nov 90 22:56:36 GMT References: <1990Nov19.050221.20537@ncsuvx.ncsu.edu> Organization: Morgan Stanley, & Co., Inc. / New York City, NY Lines: 58 George Browning writes: Is the following possible? void mycode() { if (Confirm("Do you wish to exit the program?")) exit(0); } where Confirm() displays a yes/no dialog with the question and sends a Boolean back. Here's what I do in Motif; your mileage may vary: ----- #include #include void Confirm(p, str, yesFunc, noFunc, acb) Widget p; String str; VPF yesFunc; VPF noFunc; XtPointer acb; { Widget mb; XmString msg; msg = XmStringCreateLtoR(str, XmSTRING_DEFAULT_CHARSET); FIRSTARG(XmNmessageString, msg) NEWARG(XmNdeleteResponse, XmDESTROY) mb = XmCreateWarningDialog(p, "confirm", sArgs, ArgIndex); XmStringFree(msg); if (yesFunc) XtAddCallback(mb, XmNokCallback, yesFunc, acb); if (noFunc) XtAddCallback(mb, XmNcancelCallback, noFunc, acb); XtManageChild(mb); } ----- Then I can say: SafeExit(top) Widget top; { Confirm(top, "Do you really want to exit?", exit, NULL, NULL); } /jordan