jdm@ut-ngp.UUCP (05/27/87)
I'm writing a desk accessory in Lightspeed C that puts up a simple dialog window with three EditText items. I have occasion to change the text of one of those items, using "SetIText," as I have done many times in various application programs. For some reason SetIText does not draw the new text, though Inside Mac says explicitly that it will do so (it doesn't generate an update event either). I have previously found SetIText works fine in applications. Now in the DA, I call "DrawDialog,", which does properly update the display of the item, but is kludgy since it redraws all the items, even the StatText. Anybody know why SetIText doesn't work, and/or what's a better way to draw the item? Here's a code fragment containing the call's I do: --------------------------------------------------------------- ... DCtlPtr dce; /* global: device control entry */ ... main(p,d,n) { ... } ... Handle DItemHandle(itemNo) / *returns a handle to the Dialog Item "itemNo" */ int itemNo; { Rect theRect; Handle itemHdl; int type; GetDItem(dce->dCtlWindow,itemNo,&type,&itemHdl,&theRect); return(itemHdl); } SetNo(theNo,itemNo) /* set the Dialog Item "itemNo" to the number "theNo" */ int itemNo; double theNo; { Str255 theText; ftoa(theText,theNo); /* convert theNo to a Pstring */ SetIText(DItemHandle(itemNo),theText); /* <-----The Offending Call */ DrawDialog(dce->dCtlWindow); /* Why is this necessary?? */ } ------------------------------------------------------------------ Thanks for your help Jim Meiss jdm@ut-npg.UTEXAS.EDU
scott@apple.UUCP (05/29/87)
In article <5278@ut-ngp.UUCP> jdm@ut-ngp.UUCP (Jim Meiss) writes: > > I'm writing a desk accessory in Lightspeed C... > For some reason SetIText does not draw the new text,... > > Thanks for your help > > Jim Meiss > jdm@ut-npg.UTEXAS.EDU The reason is that the WindowKind of the window has been set to indicate that the window belongs to the DA rather than to indicate that the window is a dialog. The best fix is to save, set and restore the WindowKind around the SetIText call -- like this (pardon if my C is a bit rutsy): SetNo(theNo,itemNo) /* set the Dialog Item "itemNo" to the number "theNo" */ int itemNo; double theNo; { Str255 theText; int oldkind; ftoa(theText,theNo); /* convert theNo to a Pstring */ oldkind = dce->dCtlWindow->windowKind; dce->dCtlWindow->windowKind = dialogKind; SetIText(DItemHandle(itemNo),theText); dce->dCtlWindow->windowKind = oldkind; } Just for fun I'll give another approch (not as good as above but better than calling DrawDialog) is to InvalRect the item's rectangle and let the normal update mechanism handle it. I hope that there aren't too many lies here... -- --scott douglass, Apple Computer CSNet: scott@Apple.CSNet UUCP: {nsc, sun, voder, well, dual}!apple!scott AppleLink: Douglass1 Any opinions above are mine and not necessarily those of Apple Computer.