Making a pixmap object as a background.. - Motif

This is a discussion on Making a pixmap object as a background.. - Motif ; Hello, Here's my dumb program which is supposed to create a window and put a pixmap up as it's background. #include #include #include #include main(int argc, char *argv[]) { Widget main_w; XtAppContext app; Widget top; int status; Pixmap pixmap; XpmAttributes ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Making a pixmap object as a background..

  1. Making a pixmap object as a background..

    Hello,

    Here's my dumb program which is supposed to create a window and put a pixmap up
    as it's background.

    #include
    #include
    #include
    #include

    main(int argc, char *argv[])
    {
    Widget main_w;
    XtAppContext app;
    Widget top;
    int status;
    Pixmap pixmap;
    XpmAttributes attributes;

    attributes.valuemask = 0;

    /* create a simple hierarchy with a main window */
    top = XtAppInitialize(&app, "Bart", NULL, 0, &argc, argv,
    NULL, NULL, 0);

    main_w = XmCreateMainWindow (top, "main_window", NULL, 0);

    /* create a pixmap from the XPM file */
    status = XpmReadFileToPixmap(XtDisplay(top), XtWindow(main_w),
    "bart.xpm", &pixmap, NULL, &attributes);
    if (status != XpmSuccess)
    {
    fprintf(stderr, "XpmError: %s\n", XpmGetErrorString(status));
    exit(1);
    }
    else
    {
    XSetWindowBackgroundPixmap(XtDisplay(top), XtWindow(main_w), pixmap);
    }

    XtManageChild (main_w);
    XtRealizeWidget (top);
    XtAppMainLoop(app);
    }

    I can't understand why it does not work. I keep getting the following error:

    X Error of failed request: BadDrawable (invalid Pixmap or Window parameter)
    Major opcode of failed request: 53 (X_CreatePixmap)
    Resource id in failed request: 0x0
    Serial number of failed request: 99
    Current serial number in output stream: 118

    Any input appreciated,

    Ganesh

  2. Re: Making a pixmap object as a background..



    Ganesh Ramasivan wrote:
    >
    > Hello,
    >
    > Here's my dumb program which is supposed to create a window and put a pixmap up
    > as it's background.
    >
    > #include
    > #include
    > #include
    > #include
    >
    > main(int argc, char *argv[])
    > {
    > Widget main_w;
    > XtAppContext app;
    > Widget top;
    > int status;
    > Pixmap pixmap;
    > XpmAttributes attributes;
    >
    > attributes.valuemask = 0;
    >
    > /* create a simple hierarchy with a main window */
    > top = XtAppInitialize(&app, "Bart", NULL, 0, &argc, argv,
    > NULL, NULL, 0);
    >
    > main_w = XmCreateMainWindow (top, "main_window", NULL, 0);
    >
    > /* create a pixmap from the XPM file */
    > status = XpmReadFileToPixmap(XtDisplay(top), XtWindow(main_w),
    > "bart.xpm", &pixmap, NULL, &attributes);
    > if (status != XpmSuccess)
    > {
    > fprintf(stderr, "XpmError: %s\n", XpmGetErrorString(status));
    > exit(1);
    > }
    > else
    > {
    > XSetWindowBackgroundPixmap(XtDisplay(top), XtWindow(main_w), pixmap);
    > }
    >
    > XtManageChild (main_w);
    > XtRealizeWidget (top);
    > XtAppMainLoop(app);
    > }
    >
    > I can't understand why it does not work. I keep getting the following error:
    >
    > X Error of failed request: BadDrawable (invalid Pixmap or Window parameter)
    > Major opcode of failed request: 53 (X_CreatePixmap)
    > Resource id in failed request: 0x0
    > Serial number of failed request: 99
    > Current serial number in output stream: 118
    >
    > Any input appreciated,
    >
    > Ganesh

    You must realize the main_w widget before you reference its window. As
    your code is currently written, when you make the calls to
    XpmReadFileToPixmap and XSetWindowBackgroundPixmap, XtWindow(main_w)
    will return NULL since the window for that widget has not yet been
    created. Place these calls AFTER XtRealize(top).
    --
    Fred L. Kleinschmidt
    Boeing Associate Technical Fellow
    Technical Architect, Common User Interface Services
    M/S 2R-94 (206)544-5225

+ Reply to Thread