> Another thought, though...if you're having trouble reading from the
> list, why try to read from the list?  If you have it dynamically loading
> correctly, those strings need to be available to you in some other way
> (database, string array, string resource...something) so why not read
> them from the same location?

> -Ken

My current setup saves the records (packed) to a database.
>From there, I generated a list dynamically by calling:
     DmNumRecordsInCategory();
     LstSetListChoices();
     LstSetDrawFunction();
          where my draw function...
          Seeks through all the records...
          DmSeekRecordInCategory();
          DmQueryRecord();
          and after unpacking...
          DrawCharsToFitWidth();

My goal is to determine which item in the list was chosen, get the key
from that info and pull up a record from another database? So I thought I
could just copy the string using StrCopy(listText,
LstGetSelectionText(list,LstGetSelection(list)))
But I can't figure out how I'm supposed to allocate the memory properly?

If I go:
listText MemPtr(sizeof(LstGetSelectionText(list,LstGetSelection(list))))
I get a return value of 4, which I thought was the size of the pointer...
I'm getting way off track here... but I'm at a loss here. How do I access
this info?

Thanks for all feedback thus far.. :)


Nole




                                                                                       
                                                 
                    kcorey                                                             
                                                 
                    <[EMAIL PROTECTED]>            To:     "Palm Developer Forum" 
<[EMAIL PROTECTED]>            
                    Sent by:                                 cc:     (bcc: Nole 
Mailey/pmc)                                             
                    [EMAIL PROTECTED]        Subject:     Re: LstGetSelectionText() - 
Memory Allocation ?!?!            
                    palmos.com                                                         
                                                 
                                                                                       
                                                 
                                                                                       
                                                 
                    08/04/2003 08:55 AM                                                
                                                 
                    Please respond to "Palm Developer                                  
                                                 
                    Forum"                                                             
                                                 
                                                                                       
                                                 
                                                                                       
                                                 




On Mon, 2003-08-04 at 14:53, bullshark wrote:
> On Mon, 4 Aug 2003 09:59:53 +1000, "Alan Ingleby"
<[EMAIL PROTECTED]> wrote:
> >
> >Ken's right.  Specifically, you *can't* use LstGetSelectionText with a
> >dynamic list, so don't.
>
> What? Why would that be? That's just wrong.
>
> This is only the case when a (suspicious) program never calls
LstSetListChoices.
> I think there is foul play here.
[...]
> If all that is involved here is a dynamic list, a DrawList callback
> is the wrong way to do it. You would only resort to this if your list
> had to display little icons or something. Even if you are doing it the
> wrong way, LstSetListChoices should still be called unless the list
> items don't have any text.

It all depends on where your strings come from.

Lately, I've done a bunch of work on lists built up from strings that
are individual records in a database.

If I wanted to be able to use LstSetListChoices, I'd need to either
1) Have a String array.
2) Allocate an array from dynamic memory for the strings and copy all
the strings into memory.
3) Open all the records, and lock them in place while the list is on the
form.

All of these take up some amount of space.  Arguably, if you're only
going to display 10 items, big woop.  If you're going to display up to
100, now you're potentially chewing up large amounts of memory.

Using a custom-drawn list gets around this nicely, and it's a piece of
cake, also giving you the ability to draw graphics, change fonts, or do
whatever bit of wizardry you'd like in the list.

Besides, do it once, and the code for the custom drawn list become
boiler plate, as the functionality is quite similar.

-Ken



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





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

Reply via email to