Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!jpl-devvax!david From: david@jpl-devvax.JPL.NASA.GOV (David E. Smyth) Newsgroups: comp.windows.x Subject: Re: Help on XrmGetResource Message-ID: <11524@jpl-devvax.JPL.NASA.GOV> Date: 21 Feb 91 00:32:20 GMT References: <1991Feb20.215859.18081@bellcore.bellcore.com> Reply-To: david@jpl-devvax.JPL.NASA.GOV (David E. Smyth) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 88 dfs@bellcore.com (Deborah Swayne) writes: >ms@cerc.wvu.wvnet.edu (Mark Starvaggi) posts: > >> I am having a problem retrieving resources from the resource manager database. >> I am able to load a file into the database using XrmGetFileDatabase, but I >> cannot retrieve the information from the database. > >What he said. I'm successful at reading in a resource file, but >when I then initiate, as a subroutine, the program I want to use >those resources, they are ignored. I must be doing something >wrong, or more likely failing to do something, but I don't know what. I'm guessing at your problems: You must merge the database into the display structure, and you must load the resource values you are getting from the Xrm database into a structure - don't put them straight into variables (some machines barf). Here is some excerpts from Wcl (the Widget Creation Library): if ((rdb = XrmGetFileDatabase( name )) != NULL ) XrmMergeDatabases (rdb, &(dpy->db) ); else /* do some error processing - file was not a readable resource file */ Note that the database must be merged with the existing database on the display connection. The original database is built during toolkit initialization. Here is an example of pulling data from the database for a widget: XtGetApplicationResources ( root, &res, wc_resources, XtNumber(wc_resources), NULL, 0 ); root is the widget I'm getting resources for, res is a structure whose members are loaded with values due to this call, wc_resources is the XtResources structure which describes the resource name and type, the final NULL and O are args and numArgs which I never use (I put the default values in the wc_resources struct). Specifically, here is the res struct and wc_resources struct declatations: typedef struct _ResourceRec { String resFile; /* additional resource file name */ String children; /* list of children names to create */ String popups; /* list of popup children to create */ WidgetClass class; /* widget class pointer */ WidgetClass classFromName; /* widget class pointer */ ConCacheRec* constructor; /* ptr to Constructo cache record */ Boolean managed; /* created managed (default TRUE) */ Boolean deferred; /* deferred creation, (def FALSE) */ Boolean trace; /* creation trace required */ XtCallbackList callback; /* creation callback list */ } ResourceRec, *ResourceRecPtr; ResourceRec res; XtResource wc_resources[] = { { WcNwcResFile, WcCWcResFile, XtRString, sizeof(String), XtOffset(ResourceRecPtr, resFile ), XtRImmediate, (caddr_t) NULL }, { WcNwcChildren, WcCWcChildren, XtRString, sizeof(String), XtOffset(ResourceRecPtr, children ), XtRImmediate, (caddr_t) NULL }, { WcNwcPopups, WcCWcPopups, XtRString, sizeof(String), XtOffset(ResourceRecPtr, popups ), XtRImmediate, (caddr_t) NULL }, { WcNwcClass, WcCWcClass, WcRClassPtr, sizeof(caddr_t), XtOffset(ResourceRecPtr, class ), XtRImmediate, (caddr_t) NULL }, { WcNwcClassName, WcCWcClassName, WcRClassName, sizeof(caddr_t), XtOffset(ResourceRecPtr, classFromName ), XtRImmediate, (caddr_t) NULL }, { WcNwcConstructor, WcCWcConstructor, WcRConstructor, sizeof(caddr_t), XtOffset(ResourceRecPtr, constructor ), XtRImmediate, (caddr_t) NULL }, { WcNwcManaged, WcCWcManaged, XtRBoolean, sizeof(Boolean), XtOffset(ResourceRecPtr, managed), XtRImmediate, (caddr_t) TRUE }, { WcNwcTrace, WcCWcTrace, XtRBoolean, sizeof(Boolean), XtOffset(ResourceRecPtr, trace), XtRImmediate, (caddr_t) FALSE }, { WcNwcCallback, WcCWcCallback, XtRCallback, sizeof(XtCallbackList), XtOffset(ResourceRecPtr, callback ), XtRImmediate, (caddr_t) NULL } };