Ben Combee wrote:

data in the form to point to the new location. Unfortunately, the code for this in several versions of Palm OS is a bit naive, and it will also alter text labels if the text just happens to match the characteristics of what it's looking for.

I just wanted to add, in case anyone is still tempted to use dynamic control creation in any serious way after reading this, that I've run into several other very strange problems as well:


1. Creating controls with IDs greater than 16422 or thereabouts seems to trigger strange (crashing) behaviour in at least some versions of Palm OS.
2. Sometimes, if you create enough controls, you can get the form to trash the heap. This seems to be a limit on the number of controls, or maybe just the number of lists.
3. Removing controls just doesn't work sanely (there's a workaround, but it's totally impractical for my application).


I'm not absolutely certain about the first two; I stopped short of making demo apps that exploit the bugs. Really a bugfix won't help me anyway, because I still need to support buggy ROMs that have already shipped.

What I'd very much appreciate is for these (and other!) bugs to be documented in the Palm OS reference documentation. It's pretty frustrating to find out now that PalmSource has known for years that dynamic controls are broken in several important ways, but chose not to mention it. I made application architecture decisions based on this (lack of) information, which turned out to be a pretty big mistake.

I think it's a much safer thing for someone to write a "build form" library that builds a new form in resource form in memory, then creates a form from that. It would work on any version of Palm OS, and it would allow creating a form at runtime, although it wouldn't let you easily alter a form while it is being used.

This is one fairly attractive solution for the problem domain I'm dealing with (dynamically generating forms based on a data description).


Another one with different tradeoffs is to statically add a pool of hidden controls to the form at design time: then as you need controls, you unhide them and move them into place. It's simple but effective. Both of these solutions also have the advantage of letting you use non-default values for attributes that you can't normally manipulate at runtime, like the button frame style.

--
Joseph Lunderville

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

Reply via email to