On Mon, 26 Nov 2001, Michael Glickman wrote:

> You need MemHandleNew(11)  having an extra byte for trailing zero. 

Maybe, maybe not.  Better safe than sorry, though.  After looking at the
code myself it looks like half of it is pretty unnecessary... and unsafe.
You don't have the certainty that any existing buffer for the field is
going to hold the new text going in.  The same thing is better acomplished
with the following code (newhand is just another VoidHand).

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

        newhand = MemHandleNew(11);
        fldptr = MemHandleLock(newhand);
        StrIToA(fldptr, newtime);
        MemPtrUnlock(fldptr);
        FldSetTextHandle(fld, newhand);
        FldDrawField(fld);

        if (oldhand)
                MemHandleFree(oldhand);

----------------------------------------------------------------------
Brian Smith  //   [EMAIL PROTECTED]   //  http://www.arthurian.nu/
Software Developer  //  Gamer  //  Webmaster  //  System Administrator
Echelon Teasers: NSA CIA FBI Mossad MI5 Cocaine Cuba Revolution Espionage


-- 
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