I've abandoned this method because Foster's Palm OS Programming Bible says
it's too clunky and memory hungry. I'm going to use a list callback
function but I'm wondering about something I'm seeing in Foster's source.
<<<CODE>>>
#ifdef __GNUC__
CALLBACK_PROLOGUE;
#endif
...
...
#ifdef __GNUC__
CALLBACK_EPILOGUE;
#endif
<<<END>>>
I'm using Metrowerks' Codewarrior so I'm not worrying about adding this GNU
C specific in here, but I'm curious as to what it does.
"Jimi Malcolm" <[EMAIL PROTECTED]> wrote in message
news:54301@palm-dev-forum...
>
> This probably has an easy answer. It's probably something simple I'm
> overlooking but I thought I'd give you all the source to see the problem
in
> context.
>
> Here's the new code that I'm working with. The call to LstDrawList
crashes
> it saying it's reading from low memory and jibberish appears on the
screen.
> It uses SysFormPointerArrayToStrings() so watch out when looking through
> this for the string pointers to pointers. It might get a little confusing
> but it compiles fine.
>
> Here's the calling code from the MainForm's event handler routine. This
is
> where the offending MemHandle and character pointer are defined. It
warned
> me to initialize them before using them in MainFormInit(). frmCloseEvent
> releases the handle we've been using. This occurs after the user selects
an
> item in the list.
>
> <<<CODE>>>
> MemHandle hStrings = 0;
> char *pStrings = 0;
> ...
> case frmOpenEvent:
> FrmDrawForm(frmPMain);
> MainFormInit(frmPMain, &hStrings, pStrings);
> handled = true;
> break;
>
> case frmCloseEvent:
> MemHandleFree(hStrings);
> handled = true;
> break;
> <<<END>>>
>
> The MainFormInit() is passed the handle and string pointer to store the
data
> in.
>
> <<<CODE>>>
> void MainFormInit(FormPtr frmPMain, MemHandle *hStrings, char *pStrings) {
> UInt8 stringCnt;
> UInt16 topRecordInList = 0;
> UInt32 stringLength,
> offset = 0; // Offset from start of pStrings to where we are
> currently copying
> // Start at neg one because we initiate MemPtrNew with 1
> char *pTempString;
> MemHandle hRecord;
> PackedPatientType *pPatient;
> ListPtr lstPPatients = GetObjectPtr(MainPatientsList);
>
> *hStrings = MemHandleNew(1); // Just get a pointer and put a dummy size
in
> it
>
> for (stringCnt = topRecordInList; stringCnt < topRecordInList +
> MAX_HIST_VIEWABLE_ITEMS; stringCnt++) {
> if ((hRecord = DmQueryRecord(gDB, stringCnt)) == NULL)
> break; // No more records to display
> // Lock down that patient's record so we can read from it without the
Data
> Manager moving it around on us
> pPatient = MemHandleLock(hRecord);
>
> pTempString = &pPatient->firstField + pPatient->offsetLastName;
>
> stringLength = StrLen(pTempString) + 1;
>
> MemHandleResize(*hStrings, offset + stringLength);
> pStrings = MemHandleLock(*hStrings);
> StrCopy(pStrings + offset, pTempString);
> *(pStrings + stringLength - 1) = '\0';
> MemHandleUnlock(*hStrings);
> MemHandleUnlock(hRecord);
> offset += stringLength;
> }
>
> pStrings = MemHandleLock(*hStrings);
> if ((*hStrings = SysFormPointerArrayToStrings(pStrings, stringCnt)) == 0)
{
> FrmCustomAlert(ErrorAlert, "Memory: Unable to convert strings to pointer
> array to strings.", "", "");
> return;
> }
> pStrings = MemHandleLock(*hStrings);
> LstSetListChoices(lstPPatients, &pStrings, stringCnt);
> LstDrawList(lstPPatients);
> }
> <<<END>>>
>
> Thanks a ton. I've now gone through this for just over four hours
straight.
>
> --
> Jimi Malcolm
> Web Content Manager
> inburst Internet Media
> inburst.com
> jimi.malcolm@inburst
>
>
>
>
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/