According to the PalmOS Reference, if you are getting the handle to a field
so that you can edit the text, you need to remove the handle from the field
then change text & point field to handle & draw field.

textHand = FldGetTextHandle(fldPtr);
FldSetTextHandle(fldPtr, NULL);
*** do stuff to the text in the handle ***
FldSetTextHandle(fldPtr, textHand);
FldDrawField(fldPtr);

You should probably also check the value returned by FldGetTextHandle, to
make sure it is not set to NULL (NULL = handle not allocated).





> Hi all,
> 
> I am trying to execute some code which points to some text in a field
> (inputted by the user).
> I call the function below three times in succession.  Now, when I run this
> program through the debugger, the first time this function is called, it
> goes through without any errors.  When the function is called the second
> time, the program breaks and the following error occurs at the starred line:
> 
> 'memorymgr.c, Line:3706, Invalid handle'
> 
> Does anybody know why this might be?  I assume I am not freeing the memory
> chunk properly  or something.
> Any ideas on how to fix the problem?
> 
> Thanks,
> Abid
> 
> 
> {
> FormPtr     frm;
> FieldPtr    fld;
> UInt16        obj;
> Char        *p;
> MemHandle    h;
> 
> frm = FrmGetFormPtr(formID);
> obj = FrmGetObjectIndex(frm, fieldID);
> fld = (FieldPtr)FrmGetObjectPtr(frm, obj);
> *********** h = FldGetTextHandle(fld); ***************
> p = MemHandleLock(h);
> StrCopy(p, q);
> 
> 
> FldSetTextHandle(fld,h);
> MemHandleUnlock(h);
> MemSet(p, 20, 0);
> MemHandleFree(h);
> }
> 


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to