Steve wrote:

 >>When you say "the following doesn't seem to work", what doesn't work? 
Have you checked with the debugger to see if ptrToOtherForm has a valid 
value? Has the 2nd form been opened and initialized?<<

I was able to work through this.

I used FrmIntiForm(mySecondForm) to get a pointer to that form.  Then set 
that form as active and then accessed the field.  The function (called from 
the List selection handler on the first form) I used to do this is included 
below.  I'm thinking that I may be better off using FrmDoDialog.  Opinions?


[rb}

http://www.randybrown.net


static void SetFieldHandle(MemPtr ptrToText)
{
         MemHandle               newTextH;       // The text that is selected.
         MemHandle               oldTextH;       // Text that may already 
be in the field.
         MemPtr                  tempPtr;        // Pointer to newTextH.
         FormPtr                 ptrToMainForm; // Pointer to form.
         FormPtr                 ptrToSecondForm; // Pointer to form.
         FieldPtr                ptrToField;

         // Get pointer to second form
         ptrToSecondForm = FrmInitForm(frmTwo);
         // Get pointer to active form (where list is located).
         ptrToMainForm = FrmGetActiveForm();
         if (ptrToMainForm)
                 FrmSetActiveForm(ptrToSecondForm);

         //Get pointer to the field.
         ptrToField = FrmGetObjectPtr(ptrToSecondForm, 
FrmGetObjectIndex(ptrToSecondForm, fldMySecondField));

         // Allocate handle to store the text from the list (+ 16 extra).
         newTextH = MemHandleNew(StrLen(ptrToText)+16);
         // Get pointer to memory and lock.
         tempPtr = MemHandleLock(newTextH);
         // Copy list text into memory pointer.
         StrCopy(tempPtr, ptrToText);

         // Get old text handle.
         oldTextH = FldGetTextHandle(ptrToField);
         // Set the field's new text.
         FldSetTextHandle(ptrToField, newTextH);
         // Unlock the new text handle.
         MemHandleUnlock(newTextH);

         // Make the switch to the second form
         FrmEraseForm(ptrToMainForm);
         FrmDeleteForm(ptrToMainForm);
         FrmSetEventHandler(ptrToSecondForm,frmTwo_HandleEvent);
         FrmDrawForm(ptrToSecondForm);

         // Update the field.
         FldDrawField(ptrToField);

         // Free the old text handle to prevent a memory leak.
         if (oldTextH != NULL)
                 MemHandleFree(oldTextH);
}


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