RE: Damn Unions

new topic     » goto parent     » topic index » view thread      » older message » newer message

Wow,

Thank you Matt, Chris and Don Phillips.... i didn't realise it was thaT 
easy, its just that union was so new to me and the structure looked 
complicated. Don Phillips, you've made it too easy for me to understand. 
All the same thank you All

/me: I don't think i will ever meet a helpful community, like the one in 
EU

Jordah
Don Phillips wrote:
> Hey Jordah =)
> 
> Dont sweat the details on this too hard.  You have been working
> with unions all along (kinda), you just didnt know it.  Heres a
> good example I hope will make since.
> 
> wParam and lParam are 32 bit (DWORD) variables in memory.  Most
> of the time you will use them whole (same as dwOemId).  If however
> you are processing a WM_MOUSE or similar message, it is no longer
> a DWORD but two WORD's (x and y positions).  This is a union.
> It can be accessed either by DWORD or 2 WORDS.  In this case just
> declare that whole union as DWORD dwOemId.  If you need the other
> two elements, peek4u it out into a Euphoria variable and use 
> Win32Libs built in lo_word() / hi_word() to extract the parts you
> need...
> 
> Don Phillips
> 
> jordah ferguson wrote:
> > Hi All,
> > 
> > Is there some one out there who can help me link this structure
> > to euphoria. My lack of understanding of what a union is has led to 
> > this.
> > 
> > typedef struct _SYSTEM_INFO { // sinf 
> > 
> >     union { 
> >         DWORD  dwOemId; 
> >         struct { 
> >             WORD wProcessorArchitecture; 
> >             WORD wReserved; 
> >         }; 
> >     }; 
> >     DWORD  dwPageSize; 
> >     LPVOID lpMinimumApplicationAddress; 
> >     LPVOID lpMaximumApplicationAddress; 
> >     DWORD  dwActiveProcessorMask; 
> >     DWORD  dwNumberOfProcessors; 
> >     DWORD  dwProcessorType; 
> >     DWORD  dwAllocationGranularity; 
> >     WORD  wProcessorLevel; 
> >     WORD  wProcessorRevision; 
> > } SYSTEM_INFO; 
> > 
> > Jordah Ferguson.
> > 
> >

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu