Path: utzoo!attcan!uunet!lll-winken!lll-tis!helios.ee.lbl.gov!pasteur!ucbvax!hplabs!hp-pcd!hpcvlx!jack From: jack@hpcvlx.HP.COM (Jack Peterson) Newsgroups: comp.windows.x Subject: Re: Setting widget colors within the application ? Message-ID: <100920030@hpcvlx.HP.COM> Date: 8 Dec 88 22:35:01 GMT References: <8092@pasteur.Berkeley.EDU> Organization: Hewlett-Packard Co., Corvallis, OR, USA Lines: 41 / hpcvlx:comp.windows.x / Luis@postgres.Berkeley.EDU (Luis Miguel) / 9:52 am Dec 7, 1988 / I have written an application using HP Widgets, and although I can set the foreground and background colors from my app-defaults and .Xdefaults file, I have beeen unable to do so within the applicattion itself using XtSetArg (wargs[i], XtNforeground, COLOR). Thanks for your help, /Luis Luis Miguel. Computer Science Division, UC Berkeley. arpanet: luis@postgres.Berkeley.EDU uucp: {ihnp4,decvax}!ucbvax!ingres!luis at&t: (415) 642-9585 (Work) ---------- Perhaps you are not giving it the pixel value of the color but the name of the color? If you are attempting to accomplish this task after creation of the widget you need to make a SetValues call after the SetArg. There really shouldn't be any problem doing this. Here is a little conversion routine I use so I can use the color name. Pixel Str2Pix(color) char *color; { Colormap cmap; XColor color_struct; int scr = 0; cmap = XDefaultColormap(display, scr); XParseColor(display, cmap, color, &color_struct); XAllocColor(display, cmap, &color_struct); return(color_struct.pixel); } I then make the SetArg call like the following: XtSetArg(myArgs[i], XtNforeground, Str2Pix("blue")); i++; Jack Peterson HP Corvallis Workstation Operation Support Engineer