Path: utzoo!attcan!uunet!lll-winken!lll-lcc!ames!ncar!mailrus!tut.cis.ohio-state.edu!bloom-beacon!earth.cray.COM!jlf From: jlf@earth.cray.COM (John Freeman) Newsgroups: comp.windows.x Subject: Application Context Message-ID: <8902071640.AA05010@thelake.cray.com> Date: 7 Feb 89 16:40:53 GMT Sender: daemon@bloom-beacon.MIT.EDU Organization: The Internet Lines: 59 I'm trying to put together some examples for a class I'm teaching on Toolkit programming. I want to discuss application contexts, but don't quite understand their use and meaning. Could someone give me a definition? The one example I'm trying to work out is to use application contexts to do "Hello, World" on two displays, using the toolkit. As a preliminary step, I rewrote the now famous hw.c to use XtToolkitInitialize() and XtCreateApplicationContext(), and it doesn't work. The code below demonstrates the problem. If I pass a NULL pointer to XtOpenDisplay as the Application Context parameter, it works. If I pass the real XtAppContext returned from the XtCreateApplicationContext(), the program never displays anything - it goes into XtMainLoop(), but nothing happens. #include #include #include #include #include #include #define STRING "Hello, World!" Arg label_args[] = {XtNlabel, (XtArgVal) STRING }; Arg argies[5]; main(argc,argv) int argc; char **argv; { Widget toplevel, label1, label2; Display *d1p, *d2p; XtAppContext app1, app2; XtToolkitInitialize(); app1 = XtCreateApplicationContext(); /**** This works ****/ d1p = XtOpenDisplay(NULL, NULL, NULL, "Xlabel", NULL, 0, &argc, argv); #if 0 /**** This doesn't ****/ d1p = XtOpenDisplay(app1, NULL, NULL, "Xlabel", NULL, 0, &argc, argv); #endif if (d1p == NULL) { printf("XtOpenDisplay failed\n"); return; } argies[0].name = XtNscreen; argies[0].value = (XtArgVal) DefaultScreenOfDisplay(d1p); toplevel = XtAppCreateShell("XShell", "xshell", applicationShellWidgetClass, d1p, argies, 1); label1 = XtCreateWidget(argv[0], labelWidgetClass, toplevel, label_args, XtNumber(label_args)); XtManageChild(label1); XtRealizeWidget(toplevel); XtMainLoop(); }