Re: XForms: pixmap question

Michael Glickman (michg@alphalink.com.au)
Wed, 07 Apr 1999 22:18:02 +1000

# To subscribers of the xforms list from Michael Glickman <michg@alphalink.com.au> :

Eric Mao wrote:

> # To subscribers of the xforms list from Eric Mao <ericmao@leland.Stanford.EDU> :
>
> Hi all,
>
> I'm having some trouble getting pixmaps to display. When my form is not
> visible and I try to use fl_set_pixmap_pixmap, I get:
>
> X Error of failed request: BadDrawable (invalid Pixmap or Window parameter)
> Major opcode of failed request: 55 (X_CreateGC)
> Resource id in failed request: 0x0
> Serial number of failed request: 93
> Current serial number in output stream: 95
>
> Any idea what I'm doing wrong? The relevant code is pasted in below.
>
> Thanks in advance,
> Eric Mao
>
> #include <forms.h>
> #include <stdlib.h>
> #include "smallBlock.xpm"
>
> int main(int argc, char *argv[])
> {
> unsigned int width, height;
> Pixmap pixId;
> FL_FORM *form1;
> FL_OBJECT *pixmap;
>
> fl_initialize(&argc, argv, 0, 0, 0);
>
> pixId = fl_create_from_pixmapdata(fl_default_window(), smallBlock,
> &width, &height, 0, NULL, NULL, 0);
> form1 = fl_bgn_form(FL_NO_BOX, 200, 200);
> fl_add_box(FL_FLAT_BOX,0,0,200,200,"");
> pixmap = fl_add_pixmap(FL_NORMAL_PIXMAP, 0, 0, 8, 8, "");
> fl_set_pixmap_pixmap(pixmap, pixId, 0);
> fl_end_form();
>
> fl_show_form(form1, FL_PLACE_CENTERFREE, FL_FULLBORDER,"Form 1");
> fl_do_forms();
> return 0;
> }
>
> _________________________________________________
> To unsubscribe, send the message "unsubscribe" to
> xforms-request@bob.usuhs.mil or see
> http://bob.usuhs.mil/mailserv/xforms.html
> XForms Home Page: http://bragg.phys.uwm.edu/xforms
> List Archive: http://bob.usuhs.mil/mailserv/list-archives/

Honestly I don't see any problem with the code. The only illogical thing is ..
the error message. Why XCreateGC has to be called in order to assign a pixmap
to an object ? Are you sure that this is that 'fl_set_pixmap_pixmap' is the exact

place of error message ?

Anyway, you can test value of 'pixId' after calling fl_create_from_pixmapdata.
It should be non-zero, and I doubt that it is.

Here is a slightly different approach that works in my applications. You may wish
to try it

Window win;

win = fl_prepare_form_window(form, .....); // This creates the window but
does not show it
pixId = fl_create_from_pixmapdata(win, ...); // Created window , rather than
fl_default_window is
//
used as the first argument.
if (pixId == None)
{ printf ("Oh, what can I do!\n"); return 16; }
.........
fl_set_pixmap_pixmap(object, pixId, 0); // That should be all right

fl_show_form_window(form); // This shows the window at
last.

Hope, this will help you.
Michael

_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuhs.mil or see
http://bob.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuhs.mil/mailserv/list-archives/