What is a clean and correct way of creating extended gadgets?
I'm a newbie and I have been at this for some days now so if anybody
could clear this mystery up I would be obliged.
Setup:
The app I'm writing is for color enabled Palm devices only and for
PalmOS 3.5 and up. Devtools are cygwin/gcc, pilrc, prc-tools, PalmOS 3.5
SDK and Pose3.0a8.
Problem:
I've got a form with 64 gadgets on it and all have to be extended
gadgets. That is, they need to have a gadgethandler.
If I understand correctly, the difference between a normal gadget an an
extended gadget is the extended bit defined in the FormGadgetAttrType
structure. If this bit is set the FormGadgetType structure has also got
a 'handler' field which is a pointer of type FormGadgetHandlerType.
The question is; who or what sets this bit and when?
I've searched extensively (and maybe I've missed something) but the
PalmOS reference.pdf says nothing about a function to manipulate this
bit (it says your code should treat the FormGadgetType structure as
opaque) and so I thought that using FrmSetGadgetHandler would take care
of the setting of this bit. It didn't because my gadgethandler wasn't
called.
When I do not treat the structure as opaque and set the bit myself, my
handler is called after registerring it with FrmSetGadgetHandler and
everything seems to work fine for all gadgets with even objectID.
However, the gadgets with odd objectID do not get their handle set
because FrmGetObjectIndex fails.
I suspect this is a side effect of setting the gadget handlers for the
gadgets with even objectID's. Apparently, setting the bit is not enough
to create an extended gadget because additional space has to be
allocated for the gadethandler pointer field in the FormGadgetType
structure. So when you just set the extended bit and call
FrmSetGadgetHandler you write outside the bounds of the structure thus
corrupting the next resource structure or some other data. That's why my
gadgets with the odd objectID's fail when calling FrmGetObjectIndex.
So how do I create a legal extendend gadget? Would it be possible to
create an extended gadget with FrmNewGadget()? Or should it be done at
resource-editor level? (The only bit I can alter through pilrc is the
'usable' bit). Can extended gadget resources be created with Constructor
for CW? Are assumptions made above correct?
Thanx,
Gerald
PS. There are some major bugs in Listing 3.5 (palmos 3.5 gadget example)
of the PalmOS companion pdf. Copy paste won't work, B warned!
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/