Hi nisha
When you add items to a list dynamically, you either pass the
entire array of strings to the list and let the OS take care of
allocation, dealloc and other things yourself or use a callback
function to draw the list yourself. The latter approach is more
flexible but the former is easier.
See my code snippet given below -> just a starting point.
---------------
char **gFileListElements;
Char **filelist;
filelist = (Char**)MemPtrNew(4 * sizeof(Char*));
gFileListElements = filelist;
for(i = 0; i < 4; i++)
{
recordH = DmGetRecord(dbMainRef, i);
myrec = (Maindbrec*)MemHandleLock(recordH);
temprec = *myrec;
filelist[i] = (Char*)MemPtrNew(20);
StrCopy(filelist[i], temprec.fileno);
MemHandleUnlock(recordH);
DmReleaseRecord(dbMainRef, i, 0);
}
LstSetListChoices(lstFileNo, filelist, 4);
----------
Make sure you free the memory allocated in form close event.
----------------
for(i = 0; i < 4; i++)
MemPtrFree((MemPtr)gFileListElements[i]);
MemPtrFree((MemPtr)gFileListElements);
---------------
Regards
Sridhar
On Tue, 30 Jul 2002 Akhil Bhandari wrote :
>Hi,
>
>I am using list control in my GUI application in palm
>OS CodeWarrior.
>
>I am adding data in the list dynamically. I am using
>method
>LstSetListChoices() . It works fine.
>
>Now like this if a add no. of items more than the list
>visible item, a
>scroll bar appears and if i click it, program crashes.
>
>anyway if through resource if no. of items added are
>more than no. of
>visible item. program works fine..
>
>I think this scroll bar problem appears only if i add
>list items
>dynamically.
>
>Please guide me on the same.
>
>rgds,
>Nisha.
>
>
>
>
>
>
>
>
>
>--
>For information on using the Palm Developer Forums, or to
>unsubscribe, please see
>http://www.palmos.com/dev/support/forums/
The way you work tells the world who you are - Sridhar
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/