Hi Tony

After going through your message, I am not surprised that it is still
"hanging".
You refer to FreeHandle errors, but I don't see and MemHandleFree or
MemPtrFree.
Can you find the place where the error happens ? 

I also can find only one call to LstSetListChoices with NULL for a text
array!
Honestly, I never tried NULL, it might work after all if the last argument
is zero,
but from your code it doesn't look like it will always be. Can't you just
put 0
as a constant for safety ? 

Some more observations:

1.You can't free something that was not dynamically allocated.
For example, if the list choices was defined at design time
(i.e. supplied as a resource), you can't free it - this might
explain your problem.

2. No need of LstSetSelection.. while popSelectEvent processing.
At this point it has been done by PalmOS - probably this
is just a mere redundancy that won't upset system in any way.
However, you need to set the trigger text manually.

Michael



-----Original Message-----
From: Tony Valentine [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, 11 December 2001 12:40 AM
To: Palm Developer Forum
Subject: Does anyone know how to make Dynamic lists?


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/

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