This is from Neil Rhodes and Julie McKeehan's book (ISBN1-56592-856-3).

Max
--- Joe Programmer <[EMAIL PROTECTED]> wrote:
> --- Dave Mottorn wrote:
> > Do you thing fields should be avoided
> > in general?
> 
> No.  Use a label if your text never changes.  Or use
> WinDrawChars in similar situations.  Use a field when
> you want to let the user enter text.
> 
> Here are two useful functions for changing field text
> which have been posted to this forum in the past.  You
> may find them helpful.
> 
> static FieldPtr SetFieldTextFromHandle( UInt16
> fieldID, MemHandle txtH, FormPtr frmP )
> {
>   MemHandle oldTxtH;
>   FieldPtr  fldP;
> 
>   // get the field and a handle to its text
>   fldP = FrmGetObjectPtr( frmP, FrmGetObjectIndex(
> frmP, fieldID ) );
>   ErrNonFatalDisplayIf( !fldP, "missing field" );
>   oldTxtH = FldGetTextHandle( fldP );
> 
>   // set field to new text
>   FldSetTextHandle( fldP, txtH );
>   FldDrawField( fldP );
> 
>   // free old MemHandle
>   if ( oldTxtH ) MemHandleFree( oldTxtH );
> 
>   return fldP;
> 
> } // SetFieldTextFromHandle
> 
> 
> static FieldPtr SetFieldTextFromStr( UInt16 fieldID,
> Char *strP, FormPtr frmP )
> {
>   MemHandle txtH;
> 
>   txtH = MemHandleNew( StrLen( strP ) + 1 );
>   if ( !txtH )
>     return NULL;
>   StrCopy( MemHandleLock(txtH), strP );
>   MemHandleUnlock( txtH );
>   return SetFieldTextFromHandle( fieldID, txtH, frmP
> );
> 
> } // SetFieldTextFromStr
> 
> 
> __________________________________________________
> Do You Yahoo!?
> Check out Yahoo! Shopping and Yahoo! Auctions for all of
> your unique holiday gifts! Buy at http://shopping.yahoo.com
> or bid at http://auctions.yahoo.com
> 
> -- 
> For information on using the Palm Developer Forums, or to unsubscribe, please
> see http://www.palmos.com/dev/tech/support/forums/


__________________________________________________
Do You Yahoo!?
Check out Yahoo! Shopping and Yahoo! Auctions for all of
your unique holiday gifts! Buy at http://shopping.yahoo.com
or bid at http://auctions.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