> LstSetListChoices expects a list of character pointers (a list of
> addresses). You are creating an array of actual strings. Using:
>
> static char *items[] = { "AAC", "BBD", "CCA", "ADD" };
> LstSetListChoices (listP, items, 4);
>
> Should work.
That works, except on PalmOS 1.x, for what that's worth. I forget
what was the exact issue with this; either PalmOS 1.x couldn't access
this type of list when global, or maybe it was the compiler which
wouldn't compile this properly, or some combination of the two.
Another option for a static list of strings is to put the strings in a
tAIS resource ("App Info String List" in Constructor) and then build the
list of char pointers w/ SysFormPointerArrayToStrings(), eg:
MemHandle rscHandle, listHandle ;
Char *rsc, **list ;
rscHandle = DmGetResource(appInfoStringsRsc,ListRscID) ;
if ( rscHandle )
{
rsc = MemHandleLock(rscHandle) ;
listHandle = SysFormPointerArrayToStrings(rsc,nItems) ;
list = MemHandleLock(listHandle) ;
}
SysFormPointerArrayToStrings() doesn't copy the strings in the
resource--it only allocates storage for the list of pointers pointing
to the strings in the resource--so you need to keep the resource
loaded and its handle locked for the lifetime of the list (I believe).
When you're done w/ the list, then you can unlock the handle and
unload the resource.
Speaking of which, what about the memory allocated by
SysFormPointerArrayToStrings()? I assume the system will dispose of
it when an application exits, but would it be better if we freed this
ourselves w/ MemHandleFree()?
John
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html