Hi All,
Whenever I add an item to the ShortCuts Panel, and if the length of the
MACRO DATA is greater than 20, I am not getting anything on the screen ie.,
I get a blank screen. There is no error message displayed either. I am
furnishing herewith my codes snippet for you friends to go thru and help me
if u can.
Please help me to solve this problem of getting blank Screen?
Thanks in advance. Regards,
Yuva.
============================================================================
static void MainFormInit(FormPtr frmP)
{
Err err,err2;
UInt16 indx;
UInt16 len=0,i=0,ctr=0;
ListPtr lst;
Char *check4=NULL;
Char *textP;
RectangleType lstRect;
UInt32 newsize;
Char *choices;
Err error;
UInt16 itemIndex,textLen,str_length=0,lstWidth;
UInt16 itemIndex2;
// Prepare to setup the contents of the list for the main form.
// Get a pointer to the list object.
frmP = FrmGetActiveForm();
lst = FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, MainShortCutList));
for(i=0,indx=11;;indx++,i++)
{
UInt8 *data2;
UInt16 length;
namep=(Char *)MemPtrNew(200);
label=(Char *)MemPtrNew(200);
len= (5 * sizeof(UInt16))+(5 * sizeof(UInt16));
err = GrfGetMacroName(indx,namep);
if(err == 0){
err2 = GrfGetMacro(namep,data2,&len); }
if(err != 0)
{
totitems=i;
break;
}else
{
StrNCopy(label,(Char *)data2,len);
// items2[i] = (Char *)MemPtrNew(20 * sizeof(char *)+1);
items2[i] = (Char *)MemPtrNew(200);
textP=(Char *)label;
length=StrLen(namep)+5+StrLen(label);
StrCopy(items2[i],namep);
StrCat(items2[i]," - ");
if(StrCaselessCompare(textP,"@DS")==0)
{
StrCat(items2[i],"[Date Stamp]");
StrCat(items2[i],"\0");
}else if(StrCaselessCompare(textP,"@DTS")==0)
StrCat(items2[i],"[Date Time Stamp]");
StrCat(items2[i],"\0");
}else if(StrCaselessCompare(textP,"@TS")==0)
StrCat(items2[i],"[Time Stamp]");
StrCat(items2[i],"\0");
}else
{
StrNCat(items2[i],textP,length);
StrCat(items2[i],"\0");
}
}
}
// Allocate an initial block for the list choices.
ChoicesHandle = MemHandleNew(sizeof(char));
// Lock down the block and set it's initial value to an empty string.
choices = MemHandleLock(ChoicesHandle);
*choices = 0;
str_length=0;
newsize=0;
for (itemIndex = 0; itemIndex < totitems; itemIndex++)
{
textLen = StrLen(items2[itemIndex]);
newsize=100+(textLen + str_length + sizeof('\0'));
MemHandleUnlock(ChoicesHandle);
error = MemHandleResize(ChoicesHandle, newsize);
choices = MemHandleLock(ChoicesHandle);
// Check for fatal error.
ErrFatalDisplayIf(error, "Could not grow choices for list.");
// Copy the text from the record to the choices buffer.
for (ctr = 0; ctr < textLen; ctr++)
{
choices[str_length+ctr]=items2[itemIndex][ctr];
}
str_length=str_length+ctr;
choices[str_length++] = 0;
}
if(totitems)
{
// Create an array of pointers from the choices strings.
ChoicesPtrsHandle = SysFormPointerArrayToStrings(choices, totitems);
// Set the list choices from the array of pointers.
LstSetListChoices(lst, MemHandleLock(ChoicesPtrsHandle), totitems);
// Set the list choices from the array of pointers.
LstDrawList(lst);
FrmDrawForm (frmP);
}
}
==========================================
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/