Bullshark,

>>Ken's right.  Specifically, you *can't* use LstGetSelectionText with a
>>dynamic list, so don't.  

That should probably read you *can't* use LstGetSelectionText when you supplied
NULL as the itemsText pointer to LstSetListChoices.

>If all that is involved here is a dynamic list, a DrawList callback 
>is the wrong way to do it. 

Personal opinion.  Earlier, a link was made to a "recipe" on the Pam OS site
which describes static content lists, dynamic content lists, and custom-drawn
content.  (See http://www.palmos.com/dev/support/docs/recipes/lists.html#dynamic
for example.)

The last paragraph of the dynamic content method states:

  "The complexity resulting from having to remember to free the list choices
often makes this technique worse than having a custom drawing routine for the
list. However, this way works much better than having a custom drawing routine
if the list of choices is slow to generate or must be generated sequentially."

>To set dynamic list text, create the list when the need arises and
>call LstSetListChoices(). Keep your program simple and let the
>OS do the work.

IMHO, using custom draw lists is often *simpler* than creating the text,
populating the list, and freeing the memory later.    While the recipe caveat of
this not necessarily being true when the list is slow to generate, in my
experience that has never been a problem.

>I don't have any DrawList functions and I have dozens of Dynamic lists. 

And I have plenty of drawlist functions and zero using the method you prefer.

>Even then, if they contain text, LstSetListChoices should be called 
>in most cases. It is the obvious place to store the text component of the
>custom drawn list and simplifies the job of the DrawList callback.

No it doesn't.  In cases where you have a database (or database subset)
containing the data, you just read the appropriate database record and draw the
value at the coordinates passed to the drawlist function.

This takes zero additional memory allocation to hold the list of choices,
regardless of the size of the list or database, and you never have to free the
memory either.  It has the added benefit of letting you change fonts or colors,
simulate multi-colum lists easily, etc.

Very similar to drawing table rows.

Calling  a drawlist function "the wrong way to do it" for a dynamic content list
is a disservice.  In many cases, a drawlist is a trivial way to do it by simply
using the item number to map to a record index in the database, grab the data,
and draw it.

Doug

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

Reply via email to