James,
After trying to use gadgets to store data, and wasting a LOT of time trying
to get it to do what I needed it to do, I finally gave up. Not that there
aren't legitimate uses of this capability - I'm sure there are - but I found
the following limitation to be too limiting for my purposes:
A gadget "lives" only as long as the form on which it's placed. So as soon
as you leave that form, the gadget "dies" and so does the data you've
associated with it. When you come back to that form, you have to recreate
the gadget, and reassociate the data with it. For what I was trying to do,
that just didn't work.
I ended up using a database to store all my data, since when I'm done with
my app, all the data I was going to store on the gadgets has to be hot
synched back to the pc anyway. The one exception was the data that indicates
how a gadget should look (my app has 32 identical gadgets, with two possible
appearances for each of them - "usable" and "not usable"), which I chose to
store in a global UInt32, using a bit for each of them.
I'm sure there are others who have used gadget data very effectively, and
there may be ways to do what I was trying to do, but I can tell you this -
they sure aren't obvious.
Good luck,
Brian
> -----Original Message-----
> From: Richard Burmeister [mailto:[EMAIL PROTECTED]]
> Sent: Monday, June 11, 2001 11:15 AM
> To: Palm Developer Forum
> Subject: RE: Objects in data field of the Gadget
>
>
> > From: James Carlson
> >
> > I want to put a reference to an
> > object into the data field of a gadget object. I have tried,
> > ...
> > FrmSetGadgetData(frmP,8088,&myObject);
> > ...
> > however when I try to get the object with the following code ...
> > ...
> > CompositeImage compositeImage;
> > ...
> > &compositeImage = FrmGetGadgetData(frmP, FrmGetObjectIndex(frmP,
> > VRTourVRWindowGadget));
> > ...
> > I get a compilation error. So the question is:
> >
>
> The first question really is, "What is the compilation
> error?" The compiler
> tells you where the error is, *and* it tells you why it can't
> compile that
> line. At that point, you know more about the problem than we do.
>
> One error you are making is the attempt to assign whatever
> you stored to
> "&compositeImage". You can't use &anything on the left hand
> side of an
> assignment statement. (You should get an error like "not an lvalue".)
>
> Another possible error, if you are using C++, is that the
> compiler refuses
> to do an implicit type conversion from the void * that
> FrmGetGadgetData
> returns to a CompositeImage type. You solve that by forcing
> the conversion,
> e.g.,
> compositeImage = (CompositeImage)FrmGetGadgetData(frmP, ...));
>
> Although this will only work if the CompositeImage type is a
> pointer, not a
> structure.
>
> > Is it possible to store a
> > reference to an object in a Gadget's Data field?
> >
>
> You can store anything that will fit in the space occupied by
> a (void *).
> However, will that pointer be valid later when you retrieve it? That
> depends on when you store it, when you retrieve it, and what
> transpires in
> between.
>
>
> --
> For information on using the Palm Developer Forums, or to
> unsubscribe, please see http://www.palmos.com/dev/tech/support/forums/
>
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/