> 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/