I'm trying to dynamically populate a list. Here are my two helper functions to do it:
static void ListDrawFunc(UInt itemNum, RectanglePtr bounds, CharPtr *data){
#pragma unused (data)
VoidHand stringsHandle;
stringsHandle = DmQueryRecord (DB, (UInt) itemNum);
if (stringsHandle)
{
PackedWhsePtr stringsPtr;
CharPtr s;
stringsPtr = MemHandleLock(stringsHandle);
StrCopy(s, stringsPtr->record);
WinDrawChars(s, StrLen(s), bounds->topLeft.x, bounds->topLeft.y);
s += StrLen(s) + 1;
MemHandleUnlock(stringsHandle);
}
}
static void LoadList(FormPtr frmP, Word ListID){
#pragma unused(frmP)
#pragma unused(ListID)
Boolean exists=true;
ListPtr listPtr;
if (DB){ //DB opened elsewhere
listPtr = (ListPtr) GetObjectPtr(List);
LstSetListChoices (listPtr, NULL, (UInt) DmNumRecords(DB));
LstSetDrawFunction (listPtr, ListDrawFunc);
}
else{
CharPtr dummy = MemPtrNew(10);
FrmCustomAlert(databaseError, "Code DB", StrIToA(dummy,
DmGetLastErr()), NULL);
MemPtrFree(dummy);
}
}
The records successfully draw but I am unable to select any item. Does anyone have any
idea why? I do have "LoadList" responding to a popSelectEvent.
-jason
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/