Ben Combee <[EMAIL PROTECTED]> wrote (in separate messages):
> This is quite odd. As far as I can tell, the only official way in OS 3.5 to
> create an extended gadget is to use FrmNewGadget, which dynamically adds an
> extended gadget to your form.
Did you try it :-)? I think you will find that Constructor/PalmRez makes
extended gadgets just fine.
> I was wrong on this one; I did more digging and found that the FormType
> image in memory is basically a copy of the resource with various internal
> fields fixed up. This means that only a dynamically created gadget has
> space for the handler, which would explain why they didn't made
> resource-instantiated gadgets extended.
Right, so if a non-dynamically created gadget is going to be an extended
one with a handler, the resource tool (Constructor/PalmRez or PilRC) is
going to have to make the tFRM resource with an enlarged gadget struct with
room for the handler field, and set the extended bit. As of the 3.5 SDK,
PalmRez does this. When you load such a form onto a pre-3.5 device which
doesn't handle extended gadgets, you waste a few bytes of memory but the OS
doesn't notice the extra space at the end of the gadget in the tFRM and
happily treats it as an ordinary gadget. Of course, things will explode if
you call FrmSetGadgetHandler without checking that it's supported first.
Gerald's problems are due to a bug in PilRC. It allocates space for the
larger gadget structure but forgets to set the extended bit. A patch is
below. I thought we discussed this (and particularly an EXTENDED tag in
the .rcp file) when 3.5 was released, but perhaps it fell off my radar.
John
====
diff -urNp orig-pilrc-2.7b/pilrc.c pilrc-2.7b/pilrc.c
--- orig-pilrc-2.7b/pilrc.c Wed Feb 7 23:50:24 2001
+++ pilrc-2.7b/pilrc.c Thu Feb 15 11:45:25 2001
@@ -2013,6 +2013,13 @@ Control:
obj.gadget->id = itm.id;
obj.gadget->rect = itm.rc;
obj.gadget->attr.usable = itm.usable;
+ /* Since RCFORMGADGET includes the handler
+ field, we should set the extended bit.
+ FIXME: it might be better to have an
+ EXTENDED (default on?) option for GADGET in
+ the .rcp file which would control both the
+ size of the struct and this bit. */
+ obj.gadget->attr.extended = 1;
fok = frmGadgetObj;
break;
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/