> My application would like to send events that I define myself. The problem
> is that I haven't managed to figure out how to use the data section of the
> EventType structure to attach my own data to the event. I figure I can use
> any of the pre-declared structures in the data union, but how do I do if
> none of them suits my needs, i.e. I have other data info. that I would
like
> to attach.

I believe the "data.generic" field is meant for this purpose.  It is an
array of eight UInt16's.  You'll have to perform type casting or do a
MemMove.  I wrote general-purpose C++ templates for this sort of thing:

    template <class T>
    void Encode(Event &event, const T &t)
    {
        ASSERT(sizeof(t) <= sizeof(event.data.generic));    // Won't work
otherwise!
        MemMove(event.data.generic, &t, sizeof(t));
    }

    template <class T>
    void Decode(const Event &event, T &t)
    {
        ASSERT(sizeof(t) <= sizeof(event.data.generic));
        MemMove(&t, event.data.generic, sizeof(t));
    }

And for efficiency I specialized on the UInt16 type (other specializations
are possible):

    template <>
    void Encode<UInt16>(Event &event, const UInt16 &u)
    {
        event.data.generic[0] = u;
    }

    template <>
    void Decode<UInt16>(const Event &event, UInt16 &u)
    {
        u = event.data.generic[0];
    }

> Another question is, the PalmOS EvtAddEventToQueue() copies the EventType
> structure passed as parameter. Does EvtAddEventToQueue() perform a mem.
copy
> or does it do an "intelligent" copy based on the event code, i.e. struct
> member by member?

Why wouldn't these be the same?


Eric W. Sirko
Softworks Solutions, LLC



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/tech/support/forums/

Reply via email to