Scott Erickson wrote:

Hi,
Im trying to make a Popup trigger. I have 9 options (time frames) I want to place in the list. How do I set the popup trigger object to have these 9 values?




You don't say if you want to do this dynamically or not. By that I mean that you can create a list at compile time, with a certain known number of items, and item text all predefined. In GCC you would typically do this in your RCP file. I don't know the details for CW or PODS, but it must be similar.

If you don't know beforehand how many items will be in the list, or the text that you want to use will be variable, then a list draw function might be your best bet. Here is an example of the basics.

//this tells the OS what how to render the list; how many items and what function to use to draw the list elements
void mySetupList(void){
FormPtr form = FrmGetActiveForm();
ListType *lstP;


   lstP=GetObjectPointer(ListId);
   LstSetListChoices(listP, NULL, itemCount);
   LstSetDrawFunction(listP, listDrawItem);
}

//utility function
void *GetObjectPointer(Int16 objID)
{
 FormType    *frmP=FrmGetActiveForm();

 return(FrmGetObjectPtr(frmP,FrmGetObjectIndex(frmP,objID)));
}

//this is where you find the list item text and draw it onscreen
void listDrawItem (Int16 itemNum, RectangleType *r, Char **unusedP)
{
   char    *st;

//use itemNum to find the info to display. Perhaps there is a list called "TargetList" containing the strings you want to use
st=TargetList[itemNum];
//you may want to validate that the displayed length of st will fit within the bounds of the list, in which case you will only display a certain number of chars.
WinDrawChars(st, StrLen(st), r->topLeft.x, r->topLeft.y);
}


You also have to handle the drawing of the popup trigger yourself. If you are using a string array then you can feed the control a pointer to the correct list element, of if you are just doing custom stuff then you could define a string buffer and feed that pointer to the trigger control. In either case, you need to return TRUE after any popSelectEvent on that trigger, or the trigger will try to repaint itself and crash.

Bob.

--
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/

Reply via email to