I had tried to do these,but it got the same result,:-(
My IDE: cw9, Palm Emulator 3.5, Win2k sp3.
I use LstSetDrawFunction() to draw list.
// draw list in frmOpenEvent:
lstP = (ListPtr) GetObjectPtr(MainCountryList);
LstSetDrawFunction(lstP, (ListDrawDataFuncPtr)MainListDrawFunc);
LstSetListChoices(lstP, NULL, 5);
static void MainListDrawFunc(UInt16 itemNum, RectanglePtr bounds, Char
**itemsText)
{
WinDrawChars(ListCountry[itemNum], StrLen(ListCountry[itemNum]),
bounds->topLeft.x, bounds->topLeft.y);
}
//ListCountry define:
Char ListCountry[5][10] =
{
{"China"},
{"England"},
{"France"},
{"Russian"},
{"American"}
};
"Arthur Roolfs" <[EMAIL PROTECTED]> ??????:[EMAIL PROTECTED]
>
>
> - LstGetSelection can return -1. You need to check for that
>
> - Why are you doing this:
>
> StrCopy(label, LstGetSelectionText(lstP, LstGetSelection(lstP)));
>
> and then this?
>
> label = LstGetSelectionText(lstP, 2);
>
> - Don't pass NULL to FrmCustomAlert. Give it a " " (including space) if
> you don't want to pass anything.
>
> Arthur
>
> > I used follow code to get selected text in List.
> > //MainCountryList items are:
> > // China,England,France,Russian,American
> >
> > // Main codes
> > Char *label;
> > ListPtr lstP;
> >
> > lstP = (ListPtr) GetObjectPtr(MainCountryList); // MainCountryList
> > label = MemPtrNew(32);
> > if (label)
> > {
> > StrCopy(label, LstGetSelectionText(lstP, LstGetSelection(lstP)));
> > label = LstGetSelectionText(lstP, 2);
> >
> > // ControlValueAlert message's format is " ^1 is ^2"
> > FrmCustomAlert(ControlValueAlert,"ListCountry", label, NULL);
> > MemPtrFree(label);
> > }
> >
> > // GetObjectPtr define
> > static void * GetObjectPtr(UInt16 objectID)
> > {
> > FormPtr frmP;
> >
> > frmP = FrmGetActiveForm();
> > return FrmGetObjectPtr(frmP, FrmGetObjectIndex(frmP, objectID));
> > }
> > // End main codes
> >
> > The app will open the alert window when I selected any item,
> > and the message is "ListCountry is xxx",but the "xxx" isn't any item's
> > text
> > in MainCountryList,it's a random string.
> >
> > I think that is a point error! but I can't find where is error?
> >
> > Who can help me? Thanks!
> >
> > Sean Yang
> > 22, Feb, 2003
> >
> > I
> >
> >
> >
> >
> >
> >
> >
> > --
> > For information on using the Palm Developer Forums, or to unsubscribe,
> > please see http://www.palmos.com/dev/support/forums/
> >
>
>
>
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/