On Sat, 14 Aug 2004 23:09:31 -0300, Gl�ucio Barizon Pan�ardes <[EMAIL PROTECTED]>
wrote:
I am trying to place a text in the field of my cadaster form, the field
code,
This routine might help you populate fields with text.
--Mike Y.
/***********************************************************************
FUNCTION: SetFieldText()
DESCRIPTION:
Set a field with given text. Found this routine
in Palm's online training for Palm OS 5.0.
*pFld field pointer
*pSrcStr source string
fDrawNow set to true if form already drawn, otherwise false
***********************************************************************/
void SetFieldText(FieldType *pFld, Char *pSrcStr, Boolean fDrawNow)
{
MemHandle hString;
UInt16 uwSize;
Char * pText;
// Clear field if passed a null pointer
if (!pSrcStr || !*pSrcStr) {
FldFreeMemory(pFld);
FldSetTextHandle(pFld, NULL);
// Draw field (only if form is already drawn)
if (fDrawNow) {
FldEraseField(pFld);
FldDrawField(pFld);
}
return;
}
// Allow space for null char
uwSize = StrLen(pSrcStr) + 1;
// Get current handle if it exists and reset the field
hString = FldGetTextHandle(pFld);
FldSetTextHandle(pFld, NULL);
if (hString) {
// Resize the existing handle, if it exists
if (MemHandleResize(hString, uwSize))
goto Exit;
} else {
// Must create a new handle
hString = MemHandleNew(uwSize);
if (!hString)
return;
}
// Copy over the new text
pText = MemHandleLock(hString);
StrCopy(pText, pSrcStr);
MemHandleUnlock(hString);
Exit:
// Set the new text handle
FldSetTextHandle(pFld, hString);
// Draw field (only if form is already drawn)
if (fDrawNow) {
FldEraseField(pFld);
FldDrawField(pFld);
}
}
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palmos.com/dev/support/forums/