Boolean SetFieldText(FormPtr pForm, Int16 resourceNo, Char *s, Boolean redraw )
{
SetFieldTextFromStr(getObjectPtr(pForm,resourceNo),s,redraw);
}
Boolean SetFieldTextFromStr(FieldPtr field, Char *s, Boolean redraw)
{
MemHandle h;
h=FldGetTextHandle( field );
if(h){
Err err;
FldSetTextHandle(field, NULL);
err=MemHandleResize(h, StrLen(s)+1);
if(err!=errNone){
FldSetTextHandle(field, h);
/*return err;*/
return false;
}
}else{
h=MemHandleNew(StrLen(s)+1);
if(!h)
/*return memErrNotEnoughSpace;*/
return false;
}
StrCopy((Char *)MemHandleLock(h), s);
MemHandleUnlock(h);
FldSetTextHandle(field, h);
if(redraw)
FldDrawField(field);
/*return errNone;*/
return true;
}
void *getObjectPtr (FormPtr pForm, Int16 resourceNo)
{
UInt16 objIndex=FrmGetObjectIndex(pForm,resourceNo);
return FrmGetObjectPtr(pForm,objIndex);
}
void ClearFieldText(FieldPtr field, Boolean redraw)
{
SetFieldTextFromStr(getObjectPtr(pForm,resourceNo), NULL, redraw);
}
[0回]
PR