> From: Dave Lippincott [mailto:[EMAIL PROTECTED]]
> Not thinking, I decided to piggyback the form ID in the
> charPtr of the list object.
Not thinking? But that was _my_ suggestion! :-)
> But guess what, you can't retrieve the list pointer because
> FrmGetActiveForm returns NULL within the draw call back!!!
But you _can_ retrieve whatever you stashed in the list object text pointer.
Here's code for what I originally described:
// this code pops up the list
void PopupMyList( ListType *pList )
{
FormType *pForm = FrmGetActiveForm();
LstSetDrawFunction( pList, DrawListItem );
LstSetListChoices( pList,
// NOTE: stash form ptr in list:
( char ** )( pForm ),
GetNumberOfItemsInList());
LstPopupList( pList );
}
// and here is the draw callback function
void DrawListItem( Int16 itemNum,
RectangleType * bounds,
char ** cookie )
{
// NOTE: fetch the stashed form ptr from list:
FormType *pForm = ( FormType * )( cookie );
// ...then draw stuff...
}
This shows passing a form pointer to the callback via the cookie value. You
could pass a form ID there instead. Or if you need to give the callback
even more context (such as a form pointer _and_ a database handle or memory
handle) then you can create a little struct containing those things, and
then pass the address of this structure as the cookie.
-slj-
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html