Ok, I took a look at the code (it's about 2 years old), and here's what it
seems to be doing...

The design is that there is a blank form on which buttons are added with
CtlNewControl.  The actual data describing the form is in a database, and
the user can add/delete/change/move buttons and specify the labels.  There
is no form resource that describes the screen image - it is all dynamically
created with CtlNewControl as part of handling a frmLoadEvent.

A corruption sometimes occurs that destroys the label of at least one
control currently on the screen.  It's not the control that was just added -
it's one that was already correctly displayed.  I think that what happens is
that adding a new control requires that the entire form structure be
recreated.  The bug is that in some cases a label does not get properly
copied from the old structure to the new one.

The corruption seemed to occur when the 18th or so button was added.
Examination of the control block structure all looked ok, except that things
had moved around, and the label data was bad.  This was OS 3.5, so the
source code is available, and the control blocks are real (not shadowed like
in OS 5).

The fix is to scan the labels for all controls in the active form every time
a control is added or deleted.  Do a CtlGetLabel for each control.
CtlGetLabel returns a pointer to the label.  It is compared with StrCompare
to the database info, and rewritten with StrCopy if it doesn't agree.

The key is that using CtlNewControl can trigger damage to another control.
There's nothing wrong with how CtlNewControl is called, or with the other
controls currently active.  The damage (in my case) can be corrected by
rewriting the label data.  Note also that the maximum length of the label
data is defined as part of the CtlNewControl.  To use a label that is longer
than the original definition, you have to delete the old control and define
a new one with enough space.

Palm recommends Glue...  I find that chewing gum is also useful...



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

Reply via email to