Perhapse it should be:

ww.pappl[0].pappw
ww.pappl[1].pappw
ww.pappl[2].pappw

The following simplified program works as expected

/******************************/
#define NULL 0

main()
{
    char i;
    struct WM_menw { int x; int y;};
    struct WM_appw { int x; int y;};
    struct WM_appl { struct WM_appw *p; };
    static struct WM_menw mw0 =
    {
           1,
           2
    };

    static struct WM_appw aw1 =
    {
          3,
          4
    };

    static struct WM_appw aw2 =
    {
          5,
          6
    };
    static struct WM_appl appl[4] = {(struct WM_menw *)&mw0, &aw1, &aw2,
NULL};


    printf ( "%d,%d,%d\n", appl[0].p - &mw0, appl[1].p - &aw1, appl[2].p -
&aw2 );
    for ( i=0; i<4; i++)
    {
          if ( appl[i].p != NULL )
                printf ( "%d %d\n", appl[i].p->x, appl[i].p->y );
    }
    getchar();
}
/***************************************/

Do you see any differences to what your trying to do?

Jon.

----- Original Message ----- 
From: "James Hunkins" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Saturday, November 19, 2005 5:42 AM
Subject: [ql-users] struct WM_menw size issue in C68 - qptr


> Guys,
>
> I have hit a strange behavior with C68 in the qptr windows
> environment.  Perhaps someone has some idea of what is going on.  It
> has to do with trying to use menu structures for app windows.
>
> When I try to use the following structure for one of my app windows,
> it seems to be reserving the wrong size when I setup it up, causing
> problems with accesses to any app windows following the first use of
> the structure.
>
> static struct WM_menw mw0 =
> {
> ...
> }
>
> static struct WM_appw aw1 =
> {
> ...
> }
>
> static struct WM_appw aw2 =
> {
> ...
> }
>
> static struct WM_appl appl[4] = {(struct WM_menw *)&mw0, &aw1, &aw2,
> NULL};
>
> It draws OK but when I access the structure from the WM_appl_t part,
> it has problems.
>
> What I found is:
>
> sizeof(struct WM_menw) = 172 -> correct
> sizeof(struct WM_appw)  = 104 -> correct
>
> &mw0 = 0x9da162 &aw1 - &mw0 = 0xAC = 172 -> correct
> &aw1 = 0x9da20e &aw2 - &aw1 = 0x68 = 104 -> correct
> &aw2 = 0x9da276
>
> ww.pappl->pappw[0] = 0x9da162 == &mw0 -> correct
> ww.pappl->pappw[1] = 0x9da1ca != &aw1 -> error
> ww.pappl->pappw[2] = 0x9da232 != &aw2 -> error
>
> I would have assumed that the struct WM_appl would be storing the
> true values for the addresses of mw0, aw1, and aw2.  But as you can
> see, the values are different when I read them back.
>
> In fact, the difference between pappw[1] and pappw[0] = 0x68.
> Further tests show that no matter what I do, the values stored in the
> pappl structure always seem to be incremented by 0x68, no matter what
> the real address that each entry points to.
>
> In qptr_h:
> struct WM_appl
>   {
>   WM_appw_t *pappw;
>   }
>
> It looks like this is actually a pointer as I would have expected.
>
> This would seem to be either a bug in C68 where C68 is overwriting
> the pointer values in the WM_appl structure based on the first entry
> and the standard space for struct WM_appw.  Or it is something that I
> am just not understanding.
>
> Since the original data structure is reserving the correct spaces and
> there is no problem with that, my current work around is to save off
> some global variables pointing to &mw0, &aw1 and &aw2 and not rely on
> the ww.pappl-> entries.
>
> Any suggestions/comments?
>
> Thanks,
> jim
>
> _______________________________________________
> QL-Users Mailing List
> http://www.q-v-d.demon.co.uk/smsqe.htm

_______________________________________________
QL-Users Mailing List
http://www.q-v-d.demon.co.uk/smsqe.htm

Reply via email to