I have been going through the many posts on creating dynamic lists, but
unfortunately none of them have solved my problem.

I am getting FreeHandle errors out the wazoo.  Immediately when I run the
app the second time.  And even when I sync it sometimes.  Sometimes I have
to hard reset.  Basically errors everywhere!! I know this code is somehow
responsible since it worked before I added it.  The first time I run it, the
popup label is blank (I have set it before in the Update function but it
still doesn't work right) and the list bar is visible (which is should not
be) and the list is empty.  So basically everything is wrong :)

Don't look past the fact that I am new to Palm programming, so it is
probably
something stupid by me :)
Thanks for any help.  Here is my code of importance...

Char* manufName[100];  // array of manufacturers to populate list from
UInt16 manufNum[100]; // array of manufacturer numbers (different from
index)
UInt16 MFGIndex = 0;  // index of selection

//**************************************************************************
static Boolean AddInventoryFormHandleEvent(EventPtr event)
{
        Boolean         bHandled = false;

        switch( event->eType )
        {
                case frmOpenEvent:
                        AddInventoryFormOnInit();
                        bHandled = true;
                        break;

                case frmUpdateEvent:
                        UpdateAddInventoryForm();
                        bHandled = true;
                        break;

                case popSelectEvent:
                {
                        if (event->data.popSelect.listID == AddInventoryMFGList)
                        {
                                ControlPtr pCtl;
                                CharPtr label = new Char;
                                ListPtr pList;

                                MFGIndex = event->data.popSelect.selection;

                                pList = (ListPtr) GetObjectPtr( AddInventoryMFGList );
                                LstSetSelection (pList, MFGIndex);
                                StrCopy(label, manufName[MFGIndex]);
                                pCtl = (ControlPtr) GetObjectPtr 
(AddInventoryMFGPopTrigger);
                                CtlSetLabel (pCtl, label);

                                bHandled = true;
                        }
                        break;
                }
        }
        return (Bhandled);
}

//**************************************************************************
***************
static void AddInventoryFormOnInit()
{
        FormPtr pForm = FrmGetActiveForm();
        if( pForm )


                GetSuppliers(); // populates my array from database
                ListPtr pList = (ListPtr) FrmGetObjectPtr(pForm, 
FrmGetObjectIndex(pForm,
AddInventoryMFGList));

                LstSetDrawFunction(pList, DrawOneManufString);
                LstSetListChoices(pList, NULL, supRecordCount);

                UpdateAddInventoryForm();
                FrmDrawForm( pForm );
        }
}
//**************************************************************************
// I know this routine works
static void GetSuppliers()
{
        MemHandle supRecH;
        Err err;
        supRecord *supR;

        // iterate through records and populate supplier list
        for (int i=0; i<supRecordCount; i++)

                supRecH = DmQueryRecord(supDB, i);
                if (!supRecH)
                        err = DmGetLastErr();
                else
                {
                        supR = (supRecord *) MemHandleLock(supRecH);

                        manufName[i] = new Char;
                        StrCopy(manufName[i], supR->manufName);
                        manufNum[i] = supR->manufNum;

                        MemHandleUnlock(supRecH);
                }
        }
}

//**************************************************************************
****
void UpdateAddInventoryForm(void)
{       
        // this section does not work right when uncommented    

        //ControlPtr pCtl;
        //CharPtr label = new Char;
        //ListPtr pList;
                                
        // initialize drop down manuf list
        //pList = (ListPtr) GetObjectPtr( AddInventoryMFGList );
//      LstSetSelection (pList, MFGIndex);
//      StrCopy(label, manufName[MFGIndex]);
//      pCtl = (ControlPtr) GetObjectPtr (AddInventoryMFGPopTrigger);
//      CtlSetLabel (pCtl, label);
                
}
//******************************************************************************
static void DrawOneManufString(Int16 itemNum, RectangleType *bounds, Char **itemsText) 
{
        
        WinDrawChars(manufName[itemNum], StrLen(manufName[itemNum]), 
bounds->topLeft.x, bounds->topLeft.y);
}




-- 
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