Hello Everybody,

        Is there any Know or Unknown problem with Memory handling APIs under Palm 
OS 3.3?
        I have executed the Application with Palm OS 3.1, 3.3 and 3.5
        The Problem appears only in Palm OS 3.3
        One of the problems is that if I use SetFieldText Function (Symbol SDK), 
It doesn't assign the value.
        Any Idea?

        Thank You

                                        Alejandro Calvo


/***********************************************************************
  *
  * FUNCTION:    SetFieldText
  *
  * DESCRIPTION:Perform all necessary actions to set a Field control's
  *                                     text and redraw, if necesary.  Allocates a 
text handle.
  *
  *
  * PARAMETERS: nFieldID(in) - The resource ID of the field.
  *                                     pSrcText(in) - The text to copy into field.
  *                                     nMaxSize(in) - Max size that the field can 
grow.
  *                                     bRedraw(in)  - Should the text be redrawn now?
  *
  * RETURNED:   None
  *
  ***********************************************************************/
void SetFieldText( UInt nFieldID, const CharPtr pSrcText, Int nMaxSize, 
Boolean bRedraw )
{
        VoidHand hFieldText;
        CharPtr  pFieldText;
        FieldPtr pField;

        pField = GetObjectPtr( nFieldID );
        if( !pField )
                return;
                
        hFieldText = FldGetTextHandle( pField );
        if( !hFieldText )
                hFieldText = MemHandleNew( nMaxSize );

        // If already allocated, make sure it can handle nMaxSize already.
        // If not, realloc that buffer
        else
        {
                ULong curSize = MemHandleSize( hFieldText );
                if( curSize < nMaxSize )
                        MemHandleResize(hFieldText, nMaxSize ) ;
        }

        if( hFieldText )
        {
                int len = StrLen(pSrcText);
                
                pFieldText = MemHandleLock( hFieldText );
                
                if (len > nMaxSize)
                {
                        StrNCopy( pFieldText, pSrcText, nMaxSize-1);
                        pFieldText[nMaxSize-1] = '\0';
                }
                else
                        StrCopy( pFieldText, pSrcText );

                MemHandleUnlock( hFieldText );

                FldSetTextHandle( pField, hFieldText );
                FldSetTextAllocatedSize( pField, nMaxSize );
                
                FldSetMaxChars( pField, nMaxSize-1);

                FldRecalculateField( pField, true );
                if( bRedraw )
                        FldDrawField( pField );
        }
}



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