Sure. If you look at the structure of a gadget (FrmGadgetType) you'll see
that the data member is a placeholder for a void pointer. That pointer
variable can be a pointer to memory that you allocated off the dynamic heap,
or a pointer to basically anything. I use gadgets quite a lot for this
purpose. Usually in my forms initializtion code, I grab some dynamic memory
for things related to that form, and then in response to the frmCloseEvent,
I release the memory.
Use FrmSetGadgetData. and FrmGetGadgetData to set and retrieve the pointer.
Garth
----- Original Message -----
From: "Brian Smith" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Sunday, April 29, 2001 8:01 AM
Subject: RE: Avoiding globals
> On a related note: Can the data field of a gadget store ANY kind of data?
> Like a pointer to a structure, containing several data elements? If so, is
> there anything to watch out for, or is it pretty straightforward?
>
> Thanks,
>
> Brian Smith
>
> > The technique you propose could be made to work, but a more
> > compatible method would be to put a gadget on each form from
> > which you plan to access your globals, and use its data field
> > to store a handle to your global block.
> >
> > Regards,
> >
> > Jim Schram
> > Palm Incorporated
> > Partner Engineering
> >
> >
> > --
> > 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/
>
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/