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