I have a modal form to display, and I want to load a text field with a preset value when the form loads. I've found documentation that describes how to do this, but when I try it, at runtime in the POSE I get "Invalid field length". The field I'm trying to set is editable, single-line, and not dynamic size. Its max length is 15.

Could someone tell me what I'm doing wrong? Here is the code, it's in the AppHandleEvent routine. The error appears not when the meat of the following code runs, but when the form is displayed (FrmDoDialog()).

-----------------------------------------------------------
FormType*       pForm;
UInt16    whichbutton;
MemHandle textH;
FieldType *fieldP;
char *textP;

  // global search1 contains initial string
  pForm = FrmInitForm(NewSearchForm);
  fieldP = FrmGetObjectPtr(pForm, FrmGetObjectIndex(pForm,
                                              Search1Field));
  textH = MemHandleNew(100);  // changing this size doesn't help
  textP = (char *)MemHandleLock(textH)
  if (textP)
  {
      StrCopy(textP, search1);
      MemHandleResize(textH, StrLen(textP)+1);
      MemHandleUnlock(textH);
      FldSetTextHandle(fieldP, textH);
  }
  MemHandleFree(textH);
  whichbutton = FrmDoDialog(pForm);
etc.
---------------------------------------------------------------

I appreciate any guidance.

thanks,

Curtis Cameron

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

Reply via email to