I have an editable field with a scrollbar; I am attempting to set it's
text from a char array value. I am using FldSetTextHandle as follows,
and I get the error "<app-name> has just read directly from an
unallocated chunk of memory" on the FdlDraw statement. Here is the call
to this function:
setText( getObjectPtr( form, NewMsgBodyField ), b->Body );
The char array is a form-level variable that is an element of a record
structure (char[400]). I have a similar form that also has a text field
with a scrollbar, only it is not editable, and I get no errors with that
one. Also, I only get this error if the char[400] has enough characters
to require scrolling (i.e., all characters cannot be displayed). The
other odd thing I noticed that is I do not get this error if I use this
function (setText) to fill the noneditable field BEFORE I call it to fill
the editable field; I only get the error if I call setText to display
the editable field first. Has anyone had experience with this, or can
anyone see what I am doing wrong?
Thanks,
Karen Serafino
void setText( FieldPtr dstField, Char* srcText )
{
MemHandle /*fieldH,*/ oldfieldH; // Handle of field text
Char* fieldP; // Pointer to field text
oldfieldH = FldGetTextHandle(dstField); //102300 KMS
if (oldfieldH != NULL) { //102300 KMS
FldSetTextHandle(dstField,NULL); //112500 KMS
MemHandleFree(oldfieldH); //102300 KMS
} //102300 KMS
//Allocate a handle for the string
fieldH = MemHandleNew( StrLen( srcText ) + 1 );
//Lock it
fieldP = MemHandleLock( fieldH );
//Copy the string
StrCopy( fieldP, srcText );
//Unlock it
MemHandleUnlock( fieldH );
//Give it to the field
FldSetTextHandle( dstField, fieldH );
//Draw the field
FldDrawField( dstField );
return;
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/tech/support/forums/