I just use another variable and fill it with the text I want.

Here, I grap a value I call "pCount":

  UInt16   YOUR_TEXT_LENGTH = 9, YOUR_OFFSET = 4;

  recHandle = DmGetRecord(testDB, CurrentItem);
  recText = MemHandleLock(recHandle);

  pCountHandle = MemHandleNew(YOUR_TEXT_LENGTH);
  pCountText = MemHandleLock(pCountHandle);

  // first initiallize it with an array of NULL's
  MemMove(pCountText, fillerNineLong, YOUR_TEXT_LENGTH);
  MemMove(pCountText, recText + YOUR_OFFSET, YOUR_TEXT_LENGTH);
  MemHandleUnlock(pCountHandle);
  fldIndex = FrmGetObjectIndex(frm, SPECIFIEDField);
  FldSetTextHandle(FrmGetObjectPtr(frm, fldIndex), pCountHandle);

  MemHandleUnlock(recHandle);
  DmReleaseRecord(CycleCountDB, CurrentItem, 0);

Regards,
Scott



>From: "George R" <[EMAIL PROTECTED]>
>Reply-To: "Palm Developer Forum" <[EMAIL PROTECTED]>
>To: "Palm Developer Forum" <[EMAIL PROTECTED]>
>Subject: FldSetText Question
>Date: Mon, 16 Jul 2001 08:34:41 -0400
>
>I'm trying to use FldSetText to set a handle to a field. My handle is
>actually a pointer to a record in my database. I want to set portions of 
>the
>handle that correspond to database fields to different form fields. Thus I
>don't want to use FldSetTextHandle. While FldSetText is supposed to allow
>you to set the number of bytes you wish to set, it doesn't appear to be
>working right. Has anyone had any experience using FldSetText to set subset
>of a handle that's NOT a null terminated string (my database does not use
>null terminated strings for each field)? When I try it, I get a debug error
>saying "Text Block Size smaller than Text", and the field is populated with
>more data than I request (eac field hsows data up to the NULL termination,
>regardless of the size I send).
>
>Also, does FldSetText allow you to edit the field or not? I've read
>conflicting statements on this, but the latest Palm OS Reference says
>FldSetText and FldSetTextHandle allow you to edit fields in place.
>
>Below are the relevant sections of my code:
>// totalOffset holds the number of bytes at the ebginning of each record
>used to store field offset sizes.
>
>    record = cursor;
>    maxColumns = numColumns;
>    dataRecord = DmQueryRecord (dataDB, record);
>    precord = (Char*) MemHandleLock (dataRecord);
>    FrmDrawForm (form);
>    details = MemHandleNew (MemHandleSize (dataRecord) - totalOffset);
>    stringT = (Char*) MemHandleLock (details);
>    StrCopy (stringT, precord + totalOffset);
>    MemHandleUnlock (dataRecord);
>    MemHandleUnlock (details);
>    for (loopIndex = 0; loopIndex < numColumns; loopIndex++)
>    {
>     if (loopIndex == 0)
>     {
>     offset = 0;
>     fieldSize = 4;
>     }
>     else if (loopIndex == 1)
>     {
>      offset = 4;
>     fieldSize = 9;
>     }
>     else
>     {
>     offset = 12;
>     fieldSize = 9;
>     }
>     fieldIndex = FrmGetObjectIndex (form, fieldID);
>     fieldPtr = (FieldType*) FrmGetObjectPtr (form, fieldIndex);
>     FldSetText (fieldPtr, details, offset, fieldSize);
>     FldSetUsable (fieldPtr, true);
>     FldDrawField (fieldPtr);
>     fieldID++;
>    }
>
>--
>George R
>
>
>
>
>--
>For information on using the Palm Developer Forums, or to unsubscribe, 
>please see http://www.palmos.com/dev/tech/support/forums/

_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com


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