Hi,

I am making a form dynamically and adding UI objects
to it dynamically using the routines like
FrmNewLabel,CtlNewLabel,LstNewList etc. Now when I
want to change the form and try to remove the objects
from the form to draw other objects using the
FrmRemoveObject routine it is giving me the error as
"Directly reading from memory manager data structure".

-If I remove the popup trigger attached to the list it
is working perfectly  and removing all the dynamically
created controls .

The routines that I have written to create the form
and remove the objects are as follows:

static void MainFormInit(FormPtr theFormPtr)
{

RectangleType   r;
Short  x,initialx, y,initialy, width, fwidth ,
fheight;
ListPtr                 theListPtr;
ListPtr         lst;  //list handling
ControlPtr      ctl;  //list handling
SWord           x1,x2,y1,y2;
CharPtr  Label; 

FrmGetFormBounds( theFormPtr, &r );
x = r.topLeft.x + 10;
initialx = x;
y = r.topLeft.y + 20;
initialy = y;
width = r.extent.y - 10 - y;
fwidth = 60;
fheight = 12;
FrmNewLabel (&theFormPtr, kLabelID1 , Label1Text,x,y ,
stdFont);
x +=90;
FldNewField( &theFormPtr, kField1ID, x, y, fwidth,
fheight, stdFont, 8, true, true,false, false,
rightAlign, false, false, false );
y +=15;
x = initialx ;
FrmNewLabel (&theFormPtr, kLabelID2 , kLabel2Text,x,y
, stdFont);
x +=90;
FldNewField( &theFormPtr, kField2ID, x, y, fwidth,
fheight, stdFont, 8, true, true,false, false,
rightAlign, false, false, false );
y +=15;
x = initialx ;
FrmNewLabel (&theFormPtr, kLabelID3 , kLabel3Text,x,y
, stdFont);
y +=15;
x = initialx ;
FrmNewLabel (&theFormPtr, kLabelID4 , kLabel4Text,x,y
, stdFont);  //Start month 
x +=80;
CtlNewControl(&theFormPtr,kMainFieldpopupPopTriggerID,
popupTriggerCtl,"January", x,  y,0, 12,stdFont, 0,
true);
LstNewList( &theFormPtr, kListID, x, y, 60, 12,
stdFont, 5, kMainFieldpopupPopTriggerID );
theListPtr = GetObjectPtr( kListID );
FrmHideObject (theFormPtr , FrmGetObjectIndex
(theFormPtr , kListID));
if (theListPtr)
   LstSetListChoices( theListPtr, (char**)gListItems,
kListItemsCount );
y +=15;
x = initialx ; 
FrmNewLabel (&theFormPtr, kLabelID5 , Label5Text,x,y ,
stdFont);
x +=80;
CtlNewControl(&theFormPtr,
MainFieldpopupPopTriggerID1, popupTriggerCtl,NULL, x, 
y,0, 12,stdFont, 0, true);
LstNewList( &theFormPtr, kListID1, x, y, 60, 12,
stdFont, 5, kMainFieldpopupPopTriggerID1 );
theListPtr = GetObjectPtr( kListID1 );
if (theListPtr)
    LstSetListChoices( theListPtr,
(char**)gListItems1, kListItemsCount1 );
y +=15;
x = initialx ;
FrmNewLabel (&theFormPtr, kLabelID6 , Label6Text,x,y ,
stdFont);
x +=50;
CtlNewControl (&theFormPtr,kcheckboxID1,
checkboxCtl,"Fixed", x,  y,40, 12,stdFont, 1, false);
x +=50;
CtlNewControl (&theFormPtr,kcheckboxID2,
checkboxCtl,"ARM", x,  y,40, 12,stdFont, 1, false);
}




static void RemoveDynamicItems( FormPtr theFormPtr )
{
Word            theNum;
Word            theID;
FormPtr     theForm;
VoidPtr         thePtr;
Word        objind,formid;
int                     i;
        
theNum = FrmGetNumberOfObjects( theFormPtr );

        
for(i=theNum-1; i>=0 ; i--)
{
   theID = FrmGetObjectId( theFormPtr, i);
   objind = FrmGetObjectIndex( theFormPtr , theID);
   thePtr = FrmGetObjectPtr( theFormPtr, objind );
   if (thePtr)
        FrmRemoveObject( &theFormPtr, objind );
}
}


The ID's of the objects that I have ccreated are
written in a header file as follows:

#define kDynamicStartID 5000
#define kMainFormID     kDynamicStartID
#define kField1ID  kDynamicStartID+2    
#define kListID    kDynamicStartID+12    
#define kLabelID1  kDynamicStartID+4    
#define kLabelID2  kDynamicStartID+5    
#define kLabelID3  kDynamicStartID+6    
#define kLabelID4  kDynamicStartID+7    
#define kLabelID5  kDynamicStartID+8    
#define kLabelID6  kDynamicStartID+9    
#define kField2ID  kDynamicStartID+10   
#define kListID1   kDynamicStartID+14  
#define kMainFieldpopupPopTriggerID           
kDynamicStartID+13 
 #define kMainFieldpopupPopTriggerID1                
kDynamicStartID+15 
#define kcheckboxID1 kDynamicStartID+16 
#define kcheckboxID2 kDynamicStartID+17 

Can someone help me to sort out the problem .

Thanks,

Hitesh.

__________________________________________________
Do You Yahoo!?
Kick off your party with Yahoo! Invites.
http://invites.yahoo.com/

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

Reply via email to