See code below for "SetFieldTextFromStr". Chris, you are right, it DOES call
FldDrawField indirectly via "SetFieldTextFromHandle". See code below for it
too.
I think I got this function from the O'Reilly book. I call it all over the
place. Yep, I checked - I took that and a couple other utility functions
straight from the O'Reilly book on DevZone HTML version of book.
Chris Antos <[EMAIL PROTECTED]> wrote in message
news:1671@palm-dev-forum...
>
> no, CtlSetLabel does not draw the object unless it was not already drawn.
>
> however, clearly the "SetFieldTextFromStr" function is home grown. the
> source for that function is not given, but would anyone like to place bets
> that near the end of that function is a call for FldDrawField...? :-)
>
// Set text field from string
// Allocates new handle and copies incoming string
static FieldPtr SetFieldTextFromStr(Word fieldID, CharPtr strP)
{
Handle txtH;
// get some space in which to stash the string.
txtH = (Handle) MemHandleNew(StrLen(strP) + 1);
if (!txtH)
return NULL;
// copy the string to the locked handle.
StrCopy(MemHandleLock((VoidHand) txtH), strP);
// unlock the string handle.
MemHandleUnlock((VoidHand) txtH);
// set the field to the handle
return SetFieldTextFromHandle(fieldID, txtH);
}
// Set text field from handle
static FieldPtr SetFieldTextFromHandle(Word fieldID, Handle txtH)
{
Handle oldTxtH;
FormPtr frm = FrmGetActiveForm();
FieldPtr fldP;
// get the field and the field's current text handle.
fldP = FrmGetObjectPtr(frm, FrmGetObjectIndex(frm, fieldID));
ErrNonFatalDisplayIf(!fldP, "missing field");
oldTxtH = FldGetTextHandle(fldP);
// set the field's text to the new text.
FldSetTextHandle(fldP, txtH);
FldDrawField(fldP);
// free the handle AFTER we call FldSetTextHandle().
if (oldTxtH)
MemHandleFree((VoidHand) oldTxtH);
return fldP;
}
>
> ----- Original Message -----
> From: William F. Weiher III <[EMAIL PROTECTED]>
> To: Palm Developer Forum <[EMAIL PROTECTED]>
> Sent: Wednesday, February 09, 2000 8:15 AM
> Subject: RE: Please Help with "Field Ghosting Prob"
>
>
> > Some of the API functions actually draw to the screen (such as
> CtlSetLabel)
> > actually draw to the screen. You must not call any of these functions
> before
> > the form is drawn. Some of the functions (such as TblSetRowId) just
modify
> > the memory structure of the object. In this case, that data will be used
> > when FrmDrawForm actually draws the table so it should be called before
> > FrmDrawForm. The documentation is not always perfectly clear about which
> is
> > which. If the documentation says anything about redrawing the object, do
> not
> > call it before FrmDrawForm. In some cases you might have to look at the
> > actual OS code to be certain.
> >
> > -----Original Message-----
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED]] On Behalf Of John R.
> > Violette
> > Sent: Tuesday, February 08, 2000 19:54
> > To: Palm Developer Forum
> > Subject: Re: Please Help with "Field Ghosting Prob"
> >
> > See also the post titled "Modal Form" on pilot.programmer for what the
> > problem was and more code. It is solved now, but a small mystery remains
> in
> > my mind (see below about the table). Here is a summary:
> >
> > That indeed was it. I was doing this:
> >
> > case frmOpenEvent:
> > frmP = FrmGetActiveForm();
> > versionStrP = MemHandleLock (DmGetResource ('tver',
VersionID));
> > SetFieldTextFromStr(AboutFormVersionField, versionStrP);
> > urlStrP = MemHandleLock (DmGetResource ('tSTR',
> > AboutFormWebURLString));
> > SetFieldTextFromStr(AboutFormWebURLField, urlStrP);
> >
> > MemPtrUnlock(versionStrP);
> > MemPtrUnlock(urlStrP);
> > FrmDrawForm(frmP);
> > handled = true;
> > break;
> >
> > when I should have been doing this:
> >
> > case frmOpenEvent:
> > frmP = FrmGetActiveForm();
> > FrmDrawForm(frmP);
> > versionStrP = MemHandleLock (DmGetResource ('tver',
VersionID));
> > SetFieldTextFromStr(AboutFormVersionField, versionStrP);
> > urlStrP = MemHandleLock (DmGetResource ('tSTR',
> > AboutFormWebURLString));
> > SetFieldTextFromStr(AboutFormWebURLField, urlStrP);
> >
> > MemPtrUnlock(versionStrP);
> > MemPtrUnlock(urlStrP);
> > handled = true;
> > break;
> >
> > throughout every form in my app which caused this "Field Ghosting" to
pile
> > up when switching forms or to stay on the form depending on how I
> displayed
> > it. Thanks a bunch. The reason I had switched to doing it that was was
> that
> > I have a table with custom drawing and in it I still have to do this or
> else
> > the table comes up empty:
> >
> > case frmOpenEvent:
> >
> > file://FrmCustomAlert(ErrorAlert, "Received open event", NULL,
NULL);
> > // must do before draw form or else comes up empty table
> > InitializeClientListTable();
> > FrmDrawForm( frmP);
> > handled = true;
> > break;
> >
> > So why in this case do I HAVE TO draw to the form first which is
breaking
> > the rule???? I know, I know so that my table will show up, but why is it
> > different in this case and why do only FIELDS seem to ghost???
> >
> > Although the above doesn't leave garbage from the table when I dismiss
> that
> > form. I find the user interface stuff more difficult than the database
> > stuff.
> >
> > Thanks to all who provided info....
> > Later...
> >
> >
> >
> >
> >
> > Thanks to all
> > John R. Violette <[EMAIL PROTECTED]> wrote in message
> > news:1358@palm-dev-forum...
> > >
> > > See example and description of problem here...
> > >
> > > http://free.prohosting.com/~jpdrp/prob.htm
> > >
> > >
> > >
> > >
> > >
> > >
> >
> >
> >
> > --
> > For information on using the Palm Developer Forums, or to unsubscribe,
> > please see http://www.palm.com/devzone/mailinglists.html
> >
> >
> > --
> > For information on using the Palm Developer Forums, or to unsubscribe,
> please see http://www.palm.com/devzone/mailinglists.html
> >
>
>
>
--
For information on using the Palm Developer Forums, or to unsubscribe, please see
http://www.palm.com/devzone/mailinglists.html