I'm running into some strange behavior with my application. For example,
the following code is quite standard. However, the StrLen statement works
the first time, but the second time it is called for the same form field, it
causes a "just read directly from an unallocated chunk of memory" error.
Any ideas?
extern void SetFieldText(Word fieldID, CharPtr txtP)
{
Handle newTextH, oldTextH;
FieldPtr fieldP;
fieldP = GetObjectPtr( fieldID );
ErrNonFatalDisplayIf( !fieldP, "Invalid field identifier!" );
newTextH = MemHandleNew( StrLen (txtP) + 1 );
ErrNonFatalDisplayIf( !newTextH, "Out of memory!" );
StrCopy( MemHandleLock( newTextH ), txtP );
MemHandleUnlock( newTextH );
oldTextH = FldGetTextHandle( fieldP );
FldSetTextHandle( fieldP, newTextH );
FldDrawField( fieldP );
if( oldTextH )
MemHandleFree( oldTextH );
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html