BrownB a �crit :

> Hello, is it possible to enter programmatically data in text fields instead 
> getting the data from the user? For example, I need to avoid the user to 
> insert a PIN code (my application set it) during the connection to a 
> Bluetooth device, giving to the system the sequence of characters like if it 
> would be done by the user.
>
> I tried to use EvtEnqueueKey() but it doesn't work.

You may use FldSetText but the text pointer must be static (read the API 
reference). Or you can copy the text into the field text handle.

Here's my own FldCopyText procedure:


// ** FldCopyText ***
// Copy string contents to text field
// -> form : calling form
// -> fieldID : field ID
// -> text : text to write
// returns the field

FieldPtr FldCopyText( FormPtr form, UInt16 fieldID, Char *text )
{
    FieldPtr            field;
    MemHandle           handle, oldHandle = NULL;
    Char                number[ maxStrIToALen ], line[ maxStrIToALen ];
    Err                   error;


    field = ( FieldPtr ) FrmGetObjectPtrFromID( form, fieldID );
    oldHandle = FldGetTextHandle( field );

    if ( ( text != NULL ) && ( text[ 0 ] != chrNull ) )             // if there 
is any text to copy
    {
        handle = MemHandleNew( StrLen( text ) + 1 );                // create 
new text handle for field
        if ( handle == NULL )
            FrmCustomAlert( OutOfMemoryAlert, __FUNCTION__, StrIToA( line, 
__LINE__), StrIToA( number, StrLen( text ) + 1  ) );
        else
        {                                                   // copy string 
content
            StrCopy( ( Char * ) MemHandleLock( handle ), text );
            error = MemHandleUnlock( handle );
            FldSetTextHandle( field, handle );
        }
    }
    else if ( oldHandle != NULL )                                   // new text 
is empty => clear handle
        FldSetTextHandle( field, NULL );

    if ( oldHandle != NULL )
        error = MemHandleFree( oldHandle );

    return field;
}


--
Luc Le Blanc



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

Reply via email to