Greetings,

Thanks to Aaron and Ben for the quick response and
your suggestions.

First, I have tried to redraw the field and call
FrmSetFocus, but the cursor does not appear.

Second, I insert the text from the serial port to the
field directly by changing the handle, not using
FldInsert.   Here is the code that I use:

void SetFieldText(UInt16 nFieldID, const Char *
pSrcText, Int16 nMaxSize, Boolean bRedraw)
{
   MemHandle hFieldText;
   Char *  pFieldText;
   FieldPtr pField;
   Int16 len;
   UInt32 curSize;
   Err err = 0;


   pField = (FieldPtr)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 {
      curSize = MemHandleSize(hFieldText);
      if(curSize < nMaxSize) {
         //err = MemHandleResize(hFieldText,
nMaxSize);         !!!! Problem here
         FreeFieldText(nFieldID);                     
       // These 2 lines are added for temporary fix
         hFieldText = MemHandleNew(nMaxSize);
      }
   }

   if( hFieldText ) {
      len = StrLen(pSrcText);
      pFieldText = (Char *)MemHandleLock(hFieldText);
      if (len > nMaxSize) {
         StrNCopy( pFieldText, pSrcText, nMaxSize-1);
         pFieldText[nMaxSize-1] = nullChr;
      } else {
         StrCopy(pFieldText, pSrcText);
      }
      MemHandleUnlock(hFieldText);
      FldSetTextHandle(pField,(MemHandle)hFieldText);
      FldSetTextAllocatedSize(pField,nMaxSize);
      //FldSetMaxChars( pField, nMaxSize-1);         
// Not set it here because subsequent text with longer
size will
                                                     
// cause crash
      FldRecalculateField( pField, true );
      if(bRedraw)
         FldDrawField( pField );
   }
}

..........



After the last character displayed, I do this

FldDrawField((FieldPtr)GetObjectPtr(PyroTerminalCommandField));
               FrmSetFocus(frmP,
FrmGetObjectIndex(frmP, PyroTerminalCommandField));


But the cursor is nowhere to be found.

Please pass along any suggestions I may try.
Thank you very much.




______________________________________

Ben wrote:

Are you adding your text from the serial port to the
field by directly
changing the text handle or by using FldInsert?  The
second method could
leave your cursor off screen if the text is large
enough.  You may want to
move the cursor back to the beginning of the field.

--
Ben Combee
Veriprise Wireless <http://www.veriprise.com>

____________________________

Aaron wrote:


hmm.. i got bored.. so i dug into the docs for you :)

  first of all, the docs recommend that you call
FrmSetFocus()
  instead of FldGrabFocus(), and i quote:

   "You rarely need to call this function directly.
Instead,
    use FrmSetFocus, which calls FldGrabFocus for
you."

  maybe FrmSetFocus() is going something extra, and by
calling
  it directly - you might be missing something :) i
have always
  used FrmSetFocus() without any problems - good luck.

// az
[EMAIL PROTECTED]




=====
Best regards,

Van Nguyen.

__________________________________________________
Do You Yahoo!?
Get personalized email addresses from Yahoo! Mail - only $35 
a year!  http://personal.mail.yahoo.com/

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