The FormGadgetType is opaque if you are using the OS 4 SDK or later, but
from within your GadgetHandler you are allowed to access it directly (even
if you are runing on an OS 5 device). This does not solve the problem that
the SDK defines the struct type as opaque such that you will get a compile
time error if you do try and access it.

The solution if you are using the OS 4 SDK is to define your own type that
exactly matches the FormGadgetType and then cast the opaque gadget pointer
passed into the handler to your defined MyGadgetType. There is an example of
this in the gadget recipe at:

http://www.palmos.com/dev/support/docs/recipes/extended_gadgets.html

Unfortunately it looks like there was a typo in the recipe.

GadgetStructType* pGadget = (GadgetStructType*) pToGagdet; 
It should have read

MyGadgetType* pGadget = (MyGadgetType*)pToGadget;

The recipe later tells you how to define MyGadgetType.

This being said, in the OS 4 SDK update 1 (and in the OS 5 SDK) the gadget
callback function was changed

typedef Boolean (FormGadgetHandlerType) (struct FormGadgetTypeInCallback
*gadgetP, UInt16 cmd, void *paramP);

That FormGadgetTypeInCallback IS accessible directly. If you need the
gadgetID, or data you CAN just grab it directly.

-Ezekiel Sanborn de Asis
PalmSource Developer Support

*******
I am implementing a custom control using a gadget. I want to know how to get
the gadget data when the form sends the formGadgetDeleteCmd. I am using the
following code but the ActiveForm is coming back as NULL. 
FormType *form = FrmGetActiveForm(); 
GadgetData *data = ( GadgetData * )FrmGetGadgetData( form,
FrmGetObjectIndexFromPtr( form, gadgetType ) ); 

I do not know the gadget ID, nor do I have access to the form! How else can
I get the gadget data that is stored in the OPAQUE FormGadgetType * passed
in to the event handler??? Thanks, Brad Figler 


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

Reply via email to