Thanx for ur Kind attention,
Here is what i m exactly doing,
I want to fill my ListBox with some values from DB,
so i have created a dynamic array that will contain the values as per the no.
of records in DB.Then i m inserting each of those values from array inside the
ListBox.
Initially my DB doesnt contain any records,so i had set a Flag that indicates
me that a record is been inserted into DB.
Then in the Form Open Event i check this Flag and then calls my function
FillList(), which does the Rest.
But i get two Error Msgs:
Error Message:
1.)ProjectDemo(unknown version) just read from memory location 0x00038D5E,
Which is in Memory Manager Data Structures.
These Data Structures include things like the Headers precedings each Block in
a heap,as well as the heap header itself. Such an access usually means that an
application allocated a buffer(possibly with MemPtrNew) that wasn't large
enough for its purpose.When the application then tries to write the data
to the buffer,it writes off the end of the buffer ,accessing the start of the
buffer following it in memory.
2.) ProjectDemo(unknown version) just read from memory location
0x00000028,Which is in Low Memory.
"Low Memory" is defined as the first 256 bytes of memory.It should not be
directly accessed by applications under any circumstances
i had attcah my source code Plz go thru it.
--
For information on using the PalmSource Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/support/forums/
Here's the Code:-
static Boolean WelcomeFormHandleEvent(EventType *event)
{
Boolean handled = false;
FormType *pForm;
int i=0;
char *str;
switch (event->eType)
{
case frmOpenEvent:
if(WelcomeFlag==true) //Set to true when Record is inserted
into DB
{
FillList(); // This Fn fills my List Box with Customer No from
DB.
WelcomeFlag=false; //again set to false so that this Fn is not
called twice until and unless 2nd record is added
}
pForm =
FrmGetActiveForm();
FrmDrawForm(pForm);
handled=true;
break;
}//End of frmopenevent
static void FillList()
{
FormType *pForm;
ListType* plist;
UInt16 i;
UInt16 listIndex;
int numChoices = 0;
ListElements = (Char **) MemPtrNew(nbRec1 * sizeof(Char *));
//nbRec1 contains no. of Records from DB.
//ListElements is global var of type Char **;
for (i=0;i<1;i++)
{
ListElements[i] = (char *) MemPtrNew(10);
}
SelectRecord(1); //I had passed 1 as hardcode values just for testing.
//This fun. gets the record from DB into ListAraay
pForm = FrmGetActiveForm();
listIndex = FrmGetObjectIndex(pForm, Form1ListBox);
plist = FrmGetObjectPtr(pForm, listIndex);
LstSetDrawFunction(plist,(void *)Form1ListBoxDraw);
numChoices = sizeof(ListElements);
LstSetListChoices(plist,ListElements,numChoices);
FrmDrawForm(pForm);
}
static void SelectRecord(UInt16 index)
{
MemHandle recH;
DBRecordTypePtr1 recP;
UInt16 attr;
UInt32 uniqueID;
char str[10];
DmOpenDatabaseInfo(db1, &dbID, NULL, NULL, &dbCard, NULL);
recH = (MemHandle)DmQueryRecord(db1, index);
if (recH)
{
recP = (DBRecordTypePtr1)MemHandleLock(recH);
StrCopy(ListElements[m],recP->ConsumerNo_buf);
StrCopy(str,recP->ConsumerNo_buf);
m++; //m is global Uint
}
else
//Alert Msg
}
Anything wrong in this code