I have no problem doing that.  Here's a snipet of code I use.  notesPtr is a
global char*.

FormPtr         frmP = FrmGetActiveForm();
UInt16          NotesLen;

case frmOpenEvent:
    // Copy contents of notesPtr to the screen
    NotesLen = StrLen(notesPtr);
    FldSetMaxChars ((FieldPtr)GetObjectPtr(frmP, NotepadNotesField),
NotesLen);
    SetFieldText(frmP, NotepadNotesField, NotesLen, notesPtr);
    FrmDrawForm(frmP);
    FrmSetFocus (frmP, FrmGetObjectIndex(frmP, NotepadNotesField));
    handled = true;
    break;


/***************************************************************************
***********************
 * FUNCTION:    SetFieldText
 *
 * DESCRIPTION: Sets the text in a field object

****************************************************************************
**********************/
void SetFieldText(FormPtr frmP, UInt16 objectID, UInt32 fldSize, CharPtr
txtPtr)
{
    CharPtr             fldPtr;
    FieldPtr            fldP;
    MemHandle           oldTxtH, fldHandle;

    // This handle will be freed when the form is closed and the field is
destroyed
    fldHandle =  MemHandleNew(fldSize + 1);
    if (fldHandle) {
        fldPtr = (CharPtr)MemHandleLock(fldHandle);

        StrCopy(fldPtr, txtPtr);

        fldP = (FieldPtr)GetObjectPtr(frmP, objectID);
        if (fldP) {
            oldTxtH = FldGetTextHandle(fldP);

            MemHandleUnlock(fldHandle);
            FldSetTextHandle(fldP, fldHandle);

            if (oldTxtH)
                MemHandleFree(oldTxtH);
        }
    }
}

"Chris Massey" <[EMAIL PROTECTED]> wrote in message
news:102112@palm-dev-forum...
>
> I waish to set a text field's contents after the Initform but before
> FrmDrawForm ( the first time it is displayed ).  I can't get SetTextHandle
> to work as when I get the handle it's NULL, presumably because it's not
> opened yet...
>
> Chris
>
>



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

Reply via email to