Hai All
I got one problem on listbox. I am haveing two forms.
In the second form one listbox is there. When second
form loading, i am adding 150 items to listbox. When
user goes from first form to second from and return
back to first form, if user do this 15 times, i am
geting error in adding items in list box that
MemHandleResize function returning error value..
MemHandleResize is returning the memErrNotEnoughSpace
value and executing ErrFatalDisplayIF function.
i am listing code
Can any one help me
Thanks
Raj
The follwoing is the code which i used for listbox.
FormPtr frmP;
ListPtr lstptr;
Int16 itemIndex=0,numRecords=0;
Physicianptr recPhyDB;
RectangleType lstRect;
Int16 lstWidth=0,i=0,textLen=0,k=0;
MemHandle
recHandle=NULL,ChoicesHandle=NULL,ChoicesPtrsHandle=NULL;
Char * choices=NULL,TempVar[99]="";
Boolean fits;
Err error=NULL;
UInt32 choicesOffset=0;
frmP=FrmGetActiveForm();
numRecords = DmNumRecords(MyDB);
lstptr =
FrmGetObjectPtr(frmP,FrmGetObjectIndex(frmP,ListID));
FrmGetObjectBounds(frmP, index, &lstRect);
lstWidth = (short)(lstRect.extent.x - 2);
ChoicesHandle = MemHandleNew(sizeof(char));
choices = MemHandleLock(ChoicesHandle);
*choices = 0;
for(itemIndex = 0;itemIndex < numRecords; itemIndex++)
{
recHandle = DmGetRecord(MyDB,itemIndex);
recPhyDB = MemHandleLock(recHandle);
if (StrCompare(recPhyDB->Type,"1")==0)
{
i = lstWidth;
StrCopy(TempVar,recPhyDB->PhysicianCode);
StrCopy(ANPatLName[k],recPhyDB-PhysicianLName);
StrCopy(ANPatCode[k++],recPhyDB->PhysicianCode);
StrCat(TempVar,"-");
StrCat(TempVar,recPhyDB->PhysicianLName);
StrCat(TempVar,",");
StrCat(TempVar,recPhyDB->PhysicianFName);
textLen = StrLen(TempVar);
FntCharsInWidth(TempVar, &i, &textLen, &fits);
MemHandleUnlock(ChoicesHandle);
error = MemHandleResize(ChoicesHandle, textLen +
choicesOffset + izeof('\0'));
////// i am geting error here this funtion returing
the error values
ErrFatalDisplayIf(error, "Could not grow choices for
list.");
choices = MemHandleLock(ChoicesHandle);
for (i = 0; i < textLen; i++)
choices[choicesOffset + i] = TempVar[i];
choicesOffset += textLen;
choices[choicesOffset++] = 0;
}
MemHandleUnlock(recHandle);
DmReleaseRecord(MyDB, itemIndex, false);
}
ChoicesPtrsHandle =
SysFormPointerArrayToStrings(choices,(short)numRecords-1);
LstSetListChoices(lstptr,
MemHandleLock(ChoicesPtrsHandle),(short)
numRecords-1);
LstSetSelection(lstptr,m);
________________________________________________________________________
Missed your favourite TV serial last night? Try the new, Yahoo! TV.
visit http://in.tv.yahoo.com
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/