Thanks.

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Kevin
OKeefe
Sent: Monday, December 17, 2001 8:08 PM
To: Palm Developer Forum
Subject: RE: Memory Handles


>From the docs:

"If you are obtaining the text handle so that you can edit the field's
text,

you must remove the handle from the field before you do so.

If you change the text while it is being used by a field, the field's
internal structures specifying the text length, allocated size, and
word wrapping information can become out of sync. To avoid this
problem, remove the text handle from the field, change the text, and
then set the field's text handle again. For example:
/* Get the handle for the string and unlock */
/* it by removing it from the field. */
textH = FldGetTextHandle(fldP);
FldSetTextHandle (fldP, NULL);
/* Insert code that modifies the string here.*/
/* The basic steps are: */
/* resize the chunk if necessary,*/
/* lock the chunk, write to it, and then */
/* unlock the chunk. If the text is in a */
/* database record, use Data Manager calls. */
/* Update the text in the field. */
FldSetTextHandle (fldP, textH);
FldDrawField(fldP);

-----Original Message-----
From: Dave Mottorn [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 17, 2001 4:20 PM
To: Palm Developer Forum
Subject: Memory Handles


        Im still having problems with the memory handles when I update
fields on
forms - at least I think that is where the problem is.

        My main form has eight fields on it and I use this routine, and
another
version of it for strings.

void UpdateFieldTm(int newtime, ULong fieldname){
        FieldPtr fld;
        FormPtr frmP;
        VoidHand oldhand;
        CharPtr fldptr;
        Int fldIndex;


        frmP = FrmGetActiveForm();
        fldIndex = FrmGetObjectIndex(frmP, fieldname);
        fld = FrmGetObjectPtr(frmP, fldIndex);

        oldhand = FldGetTextHandle(fld);
        if (!(oldhand)) oldhand = MemHandleNew(11);
        if (MemHandleSize(oldhand) < 11) MemHandleResize(oldhand, 11);

        fldptr = MemHandleLock(oldhand);

        StrIToA(fldptr, newtime);
        FldSetTextHandle(fld, oldhand);
        FldDrawField(fld);
        MemHandleUnlock(oldhand);
}

        It seems to work ok for the main form but as soon as I load another
form
and try to update fields on it my program aborts.  I can load other forms
and close them repeatedly and redraw the main form each time with no
problem.  It seems that as soon as I update a field on another field I get
problems.

regards,

Dave Mottorn



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

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



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

Reply via email to