OK here is all of it. Again, I am getting a record from a database. The
record is
"How many employees do you have?","1-100","101-1000","More than 1000"
So all I want to do is get
** "How many employees do you have? **
part of the string and add it to the list box. Right now it is blowing up at
the ****** shown in the code. Also with my _GetLastPos() function, I
allocate the string again. Since I did a previous MemHandleLock, I shouldn't
have to do this correct? Well the Enumulator keeps on saying I have access
memory I shouldn't...
Oh also, something is getting trampled because when the the line
VoidHand vHandle = MemHandleNew(wPos + 1);
get executed, it already has a value in it. MemSet() wont clear it either.
That is what the CW debugger shows...
Thanks for any help
Ralph Krausse
----------------------------------
Word CListObject::_GetLastPos(CharPtr pszRecord)
{
VoidHand vHandle = MemHandleNew(StrLen(pszRecord) + 1);
CharPtr pNextChar = (CharPtr)MemHandleLock(vHandle);
StrCopy(pNextChar,pszRecord);
int wTotalCount = 0;
for(;*pNextChar;pNextChar++)
{
if(*pNextChar == '\"' && *(pNextChar + 1) == ',' &&
*(pNextChar + 2) == '\"')
{
break;
}
wTotalCount++;
}
MemHandleUnlock(vHandle);
MemHandleFree(vHandle);
return wTotalCount;
}
void CObject::_ListBoxDraw(Word wItem, RectanglePtr bounds, CharPtr *dummy)
{
// I get my record
VoidHand hRecord = DmQueryRecord(m_hQndADB, wItem);
if(hRecord)
{
// I lock it down
CharPtr pszRecord = (CharPtr)MemHandleLock(hRecord);
if(pszRecord)
{
// I get my pos
Word wPos = _GetQuestionLastPos(pszRecord);
VoidHand vHandle = MemHandleNew(wPos + 1);
CharPtr pListBoxEntry =
(CharPtr)MemHandleLock(vHandle);
StrNCopy(pListBoxEntry,pszRecord,wPos);
Int iWidth = bounds->extent.x;
Boolean fits;
********* Int iLength = StrLen(pListBoxEntry) + 1;
FntCharsInWidth(pListBoxEntry, &iWidth, &iLength,
&fits);
WinDrawChars(pListBoxEntry, iLength,
bounds->topLeft.x, bounds->topLeft.y);
MemHandleUnlock(vHandle);
MemHandleFree(vHandle);
}
MemHandleUnlock(hRecord);
MemHandleFree(hRecord);
}
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/