Use LstGetSelectionText to the text of a list item.

  pObj1 = GetObjectPtr(pForm, iListID)
  LstGetSelectionText(pObj1, iSelection)   // Returns a pointer to the list
text


Then use a function like the following to place the text into your field

static void SetFieldText(Word FieldId, char *Str) {

  VoidHand         hTextNew;
  VoidHand         hTextOld;
  VoidPtr          pField;
  FormPtr          pForm;
  FieldPtr         fpField;


  pForm = FrmGetActiveForm();                    // Get field pointer
  fpField = GetObjectPtr(pForm, FieldId);

  hTextNew = MemHandleNew(StrLen(Str)+16);       // Allocate memory
  pField = MemHandleLock(hTextNew);              // Get pointer to memory
and lock
  StrCopy(pField, Str);                          // Copy string

  hTextOld = (VoidHand)FldGetTextHandle(fpField);// Get old pointer to text

  FldSetTextHandle(fpField, (Handle)hTextNew);   // Set the field's new text
  MemHandleUnlock(hTextNew);                     // Unlock memory

  FldDrawField(fpField);

  if (hTextOld != NULL)                          // Free old pointer
    MemHandleFree(hTextOld);

return;


Paul...

----- Original Message -----
From: "Randy Brown" <[EMAIL PROTECTED]>
To: "Palm Developer Forum" <[EMAIL PROTECTED]>
Sent: Monday, February 19, 2001 7:35 AM
Subject: [?] Plugging List text into a Field


> Hello -
> Can someone point me to example code for transferring the contents of a
> selection from a List into a field? The list is on one form, and the field
> is on another. I know there's some memory management hoops to jump, but
> haven't been able to leap them yet.
> TIA.
>
>
> [rb}
>
> http://www.randybrown.net
>
>
> --
> For information on using the Palm Developer Forums, or to unsubscribe,
please see http://www.palmos.com/dev/tech/support/forums/
>


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