I have not gone through your source code but one of the obvious error is
your strings are stored in a local variable "items". Which gets destroyed
after you return from MainFormInit. Make it global, better still use a two
dimentional pointer along with a variable for stroing the number of elements
in "items" and free it when you don't need it.

Khurram+


----- Original Message -----
From: "Yuva Kumar" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Friday, November 09, 2001 11:00 AM
Subject: error in LstSetListChoices() function? Help required.


> Hi All,
> I am accessing Graffiti Shortcut database and getting the datas to add it
> dynamically to a popup list.  Following is the source code.  I am getting
> the datas read into a two dimension array items[][].  But when I try to
add
> it to the List, I am getting a error message.
>
> How do I add the two dimension array to the popup list.  The
> LstSetListchoices() requires list items in the Char **itemsText format.  I
> use SysFormPointerArrayToStrings() function which also returns error
> message.  How do I convert the 2dimension array to a Char ** format.
>
> Or is there any other way to get the list of Graffiti Shortcuts.  It is
> stored in Graffiti Shortcuts.PRC file with data type as "macr" and the
> creator as "graf".  Please help.
>
> Thanking you all in advance. Regards.
>
> Yuva.
>
> Note: Mr Khurram, Thank you for your timely help on my previous question.
> Could you please help me on this too.  Thanks.
>
>
============================================================================
> =
> static void MainFormInit(FormPtr frmP)
> {
>  Err err,err2;
> UInt16 indx,itemIndex;
>  RectangleType lstRect;
> Char *namep, *choices;
>  UInt16 len,textLen,str_length,lstWidth,i=0;
>  UInt16 choicesOffset=0;
> Char *label,*textP;
> UInt8 *data2;
> Char items[10][20],*ptr;
> MemHandle textH;
> Char strArray[10][30];
> UInt16 test;
> Char label2[10];
>  ListPtr  lst,lst1;
>  MemPtr p;
>  MemHandle  recHandle;
>  Err    error;
>  Boolean   fits;
>  Char *pointer;
>
>
>
>   // Prepare to setup the contents of the list for the main form.
>   // Get a pointer to the list object.
>   frmP = FrmGetActiveForm();
>   lst = FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, MainShortCutList));
>
>   for(i=0,indx=15;;indx++,i++)
>   {
>    len=sizeof(UInt32)+sizeof(UInt32);
>    err  = GrfGetMacroName(indx,namep);             file://this will get
the
> macro text using the index number.
>    err2 = GrfGetMacro (namep,data2,&len);         file://this will get the
> macro contents using the macro text.
>    label=(Char *)data2;
>    StrCopy(items[i],namep);
>    if(err != 0)
>    {
>     totitems=i;
>     break;
>    }
>   }
>
>   // Create an array of pointers from the choices strings.
>   ChoicesPtrsHandle = SysFormPointerArrayToStrings(items, 5);
>   // Set the list choices from the array of pointers.
>   LstSetListChoices(lst, &items, i);
> }
> =======================================================================
>
>
>
> --
> 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