Durgesh,

Do you need to call LstDrawList at the time that you do?  Maybe the form
isn't valid when you call it?
Try commenting it out and see if it still gets drawn.

As for the memory leak.
You need to keep track of the memory you've allocated and free it when
appropriate.
I'd rewrite the function something like this...
When you need the database list, call the function with a valid form,
when you want to clean up call 
TodayPreference(0) - on exit from your app woud be fine.
I haven't tested this, so if there are any typos, you'll have to take
care of them.
Regards
John Sutton

void TodayPreference(FormType* frm)
{ 
        SysDBListItemType          *dbListIDsP; 
        VoidHand                  dbListIDsH; 
        UInt16                     counter;  
        Boolean                    status;                 
        ListType*  lst;

        static char **ItemType; // make this static so we don't lose
track of it
        static UInt16 dbCount = 0; // make this static so we don't lose
track of it

        // Check to see if we've been called before
        if(dbCount)
        {
                // We have been called before so...
                // free up any memory we borrowed and set it so it
                // looks like we've never been called before  
                for(counter=0;counter<dbCount;counter++)
                {
                        MemPtrFree(ItemType[counter]);
                }
                MemPtrFree(ItemType);
                dbCount=0;
        }
        
        // Have we been called with a valid form or is this a clean up
        if(frm)
        {
                // This is a valid frm so produce the database list
                lst =
(ListType*)FrmGetObjectPtr(frm,FrmGetObjectIndex(frm, TodayPrefList));
                status = SysCreateDataBaseList(sysFileTApplication,
0,&dbCount, &dbListIDsH,true);
                // Were any databases found?
                if (status == true && dbCount > 0) 
                { 
                        ItemType = (Char**)MemPtrNew(dbCount *
sizeof(Char*)); 
                        // Get a lock - remember to free it later
                        dbListIDsP = (SysDBListItemType*)MemHandleLock
(dbListIDsH); 
                        for (counter = 0; counter < dbCount; counter++) 
                        {                
                                ItemType[counter] =
(Char*)MemPtrNew(dmDBNameLength+1); 
        
StrCopy(ItemType[counter],dbListIDsP[counter].name);

                        }                
                        LstSetListChoices (lst,ItemType,dbCount);    
                        LstDrawList(lst);   
                        // Unlock the handle
                        MemHandleUnlock(dbListIDsH);
                }
        }
}
-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Durgesh
Trivedi
Sent: 12 September 2006 06:42
To: Palm Developer Forum
Subject: List draw error

I m drawing a list on the frm it create two problems. 1 is  before the
LstDrawList(lst);   it gives the error messsage bad window and after it
draw the list on the form and rest of things wrk fine and 

second problem is that when i exit the application it give error message
un freed chunk why i dont understand here is my code .

static void TodayPreference(FormType* frm) { 
SysDBListItemType          *dbListIDsP; 
MemHandle                  dbListIDsH; 
UInt16                     dbCount = 0,counter;  
Boolean                    status;                 
ListType*  lst;

char **ItemType; 
       
     ItemType = (Char**)MemPtrNew(4 * sizeof(Char*)); 
    
     lst = (ListType*)FrmGetObjectPtr(frm,FrmGetObjectIndex(frm,
TodayPrefList));
        
    status = SysCreateDataBaseList(sysFileTApplication, 0,&dbCount,
&dbListIDsH,true);
   
    if (status == true && dbCount > 0) 
     { 
        dbListIDsP = (SysDBListItemType*)MemHandleLock (dbListIDsH); 
        
         for (counter = 0; counter < dbCount; counter++) 
          {              
                   ItemType[counter] = (Char*)MemPtrNew(20); 
                  
                        StrCopy(ItemType[counter],
dbListIDsP[counter].name);                               
          }    
                        
            LstSetListChoices (lst,ItemType,dbCount);
                
            LstDrawList(lst);   
            MemPtrFree(ItemType);                 
            MemPtrFree(dbListIDsP);        
     }
  }

i think the second problem is due to the ItemType[counter] =
(Char*)MemPtrNew(20); is their any other way to free the ItemType ialso
try the 

for(counter=0 ;counter<dbCount;counter++) MemPtrFree(ItemType[counter]);


it also not wrk rest of things wrk fine in the application Please help
me if any budy can.
--
For information on using the PalmSource Developer Forums, or to
unsubscribe, please see http://www.palmos.com/dev/support/forums/

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email
______________________________________________________________________

______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________

-- 
For information on using the PalmSource Developer Forums, or to unsubscribe, 
please see http://www.palmos.com/dev/support/forums/

Reply via email to