Re: XForms: pixmap question

Steve Lamont (spl@szechuan.ucsd.edu)
Wed, 7 Apr 99 07:07:19 PDT

# To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

> 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.

The problem is that you're trying to write a Pixmap into a Window
which doesn't exist yet, hence the X error. A better way to add your
image is

[...]

fl_initialize(&argc, argv, 0, 0, 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_data( pixmap, smallBlock ); /* Do this */
fl_end_form();

fl_show_form(form1, FL_PLACE_CENTERFREE, FL_FULLBORDER,"Form 1");
fl_do_forms();

[...]

Alternatively, move the call to fl_set_pixmap_pixmap() to *after* the
fl_show_form() call:

[...]

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_end_form();

fl_show_form(form1, FL_PLACE_CENTERFREE, FL_FULLBORDER,"Form 1");
fl_set_pixmap_pixmap(pixmap, pixId, 0); /* Move to here so there's */
/* Window to draw into */
fl_do_forms();

[...]

spl
_________________________________________________
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/