rgr@cbnewsm.att.com (Duke Robillard) (06/29/90)
/*
So I was writing my first X application, and I decided to use a Dialog
Widget from the Athena Widget set. This Dialog Widget puts up a box
to be filled in, a button to be pushed, and asks for a name. When
the button is pushed, the button's callback creates a new Dialog Widget,
with the box initialized to the name filled in previously. When I run
it, I get:
X Error of failed request: BadWindow (invalid Window parameter)
Major opcode of failed request: 38 (X_QueryPointer)
Minor opcode of failed request: 0
Resource id in failed request: 0x0
Serial number of failed request: 62
Current serial number in output stream: 62
This is happening on the call to XtCreateManagedWidget for the
new dialog.
If any X guru out there would like to tell me what I did
wrong, I'd be forever in his debt.
I'm using X11 R4 on a Sun 3/60. This article should compile and
demonstrate the problem (except for the news header stuff and the
signature at the end)
Thanks in Advance
Bob Robillard rgr@m10ux.att.com ...!att!m10ux!rgr
*/
#include <stdio.h>
#include <X11/StringDefs.h>
#include <X11/Intrinsic.h>
#include <X11/Dialog.h>
#include <X11/Command.h>
#include <X11/Form.h>
/* the widgets */
Widget toplevel=NULL;
Widget the_form=NULL;
Widget name_dialog=NULL;
Widget accept_button=NULL;
char *new_name;
void
NewName(w, client_data, call_data)
Widget w;
caddr_t client_data; /* unused */
caddr_t call_data; /* unused */
{
extern void CreateNameDialog();
printf("in NewName\n");
new_name= XawDialogGetValueString(name_dialog);
printf("so, the new name is %s\n", new_name);
/* build the new dialog box with the name in the old box */
CreateNameDialog(new_name);
}
void
CreateNameDialog(name)
char *name;
{
extern char *malloc();
/* args for accept button */
static Arg accept_args[10];
static XtCallbackRec accept_callbacks[] = {
{ NewName, NULL },
{ NULL, NULL }
};
char *namedialog_value;
static Arg name_args[10];
int i;
/* destroy any existing name dialog */
/*$if (accept_button != NULL) {
XtDestroyWidget(accept_button);
}
if (name_dialog != NULL) {
XtDestroyWidget(name_dialog);
}$*/
/* the new value of the dialog is the name passed in */
namedialog_value= malloc(strlen(name) + 40);
strcpy(namedialog_value, name);
/* create a new name_name dialog */
i= 0;
XtSetArg(name_args[i], XtNlabel, (XtArgVal) "Name"); i++;
XtSetArg(name_args[i], XtNvalue, (XtArgVal) namedialog_value); i++;
name_dialog= XtCreateManagedWidget("name", dialogWidgetClass,
the_form, name_args, XtNumber(name_args));
/* create the accept button */
i= 0;
XtSetArg(accept_args[i], XtNcallback, (XtArgVal) accept_callbacks); i++;
accept_button= XtCreateManagedWidget("Accept New Name", commandWidgetClass,
name_dialog, accept_args, XtNumber(accept_args));
}
void
main(argc, argv)
unsigned int argc;
char **argv;
{
extern void CreateNameDialog();
extern char *malloc();
static XrmOptionDescRec options[] = {
{"-label", "*button.label", XrmoptionSepArg, NULL}
};
/* args for the form widget */
static Arg form_args[] = {
{ XtNdefaultDistance, (XtArgVal) 5 },
};
/* build the display */
toplevel = XtInitialize("main", "AGSIMDisplay",
options, XtNumber(options), &argc, argv );
the_form=
XtCreateManagedWidget("form", formWidgetClass,
toplevel, form_args, XtNumber(form_args));
/* build the initial dialog box with name "gorf" */
CreateNameDialog("gorf");
/* put it on the screen */
XtRealizeWidget(toplevel);
/* interact */
XtMainLoop();
}
--
Duke Robillard DoD #0130
Internet: rgr@m10ux.att.com
USENET: {backbone}!att!m10ux!rgrkit@EXPO.LCS.MIT.EDU (Chris D. Peterson) (06/29/90)
> So I was writing my first X application, and I decided to use a Dialog > Widget from the Athena Widget set. Take a look at the example program "popup.c" in the examples/Xaw directory on your R4 tape. it is an example program that does exactly what you are having problems with. Chris D. Peterson MIT X Consortium Net: kit@expo.lcs.mit.edu Phone: (617) 253 - 9608 Address: MIT - Room NE43-213