> On 2006-10-17, [EMAIL PROTECTED] <[EMAIL PROTECTED]>
> wrote:
> I'm writing a background application which listens for field input in other
> apps and then edits the field. The following code gives an "Invalid
> Field Length" error after calling FldDrawField(). Am I doing anything wrong?
>
> FieldType* fldP = field ptr
> Char* fullString = null terminated string...
> MemHandle newTextH = FldGetTextHandle(fldP);
> MemHandleResize(newTextH, StrLen(fullString) + 1);
> Char* newText = (Char*)MemHandleLock(newTextH);
> DmStrCopy(newText, 0, fullString);
> MemHandleUnlock(newTextH);
> FldDrawField(fldP);
>

Before resizing dissociate the texthandle from the field:
FldSetTextHandle(fldP, NULL)
After resizing and copying associate it again:
FldSetTextHandle(flpP, newTextH)
This sets all the internal field data correctly and avoids the
"Invalid field length" error. (I hope ...)

HTH
Ton van Overbeek

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

Reply via email to