Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!sdd.hp.com!mips!cs.uoregon.edu!gla-aux!glenn From: glenn@gla-aux.uucp (Glenn L. Austin) Newsgroups: comp.sys.mac.programmer Subject: Re: QuickDraw before ModalDialog Message-ID: <1991May10.064954.3631@gla-aux.uucp> Date: 10 May 91 06:49:54 GMT References: <11147@bunny.GTE.COM> Organization: The Pit Lane Lines: 66 CAH0@bunny.gte.com (Chuck Hoffman) writes: >Running 6.0.7, using THINK C. I have my "About" information in a dialog >box used with ModalDialog. I first do some QuickDraw in the box (copybits >from the ICN#, and a dark border around the Okay button) before invoking >ModalDialog. If Pyro! 4.0 gets the screen, then gives it up again, my >QuickDraw stuff seems to go away. I'm not able to detect any events while >ModalDialog is running, and wouldn't have a way to redraw the box during >ModalDialog anyway. Am I destined always to lose the QuickDraw stuff? >Should I InvalRect the box? Is there a better way? The reason why is that, when using dialog boxes, the contents are updated via the DrawDialog mechanism. So, if you want the drawings to get redrawn, you MUST allocate a user item which covers the area to be drawn. This is so that, when an update occurs on the dialog, the intersection of the updateRgn and any dialog items designates which items will be redrawn. If there is no user item behind your graphics, then there is no way to determine that they should be redrawn. Probably the first userItem people should do is the "default button" outline. To save some time for those who haven't done one before, here's the code in C: pascal void DrawDefaultItem(DialogPtr theDialog, short itemNo) { GrafPtr oldPort; PenState oldPen; short item; Handle h; Rect box; GetPort(&oldPort); /* get the current grafport */ SetPort(theDialog); /* necessary on the Plus */ GetPenState(&oldPen); /* save the old pen settings */ PenNormal(); /* reset the pen state */ /* get the item's rectangle */ GetDItem(theDialog, itemNo, &item, &h, &box); PenSize(3,3); /* set the pen to 3 x 3 */ InsetRect(&box, -4, -4); /* inset outside of the item */ /* WARNING!!! Drawing outside */ /* of the item's rectangle can */ /* be clipped by QuickDraw! */ /* It is better to create the item */ /* with the correct size in the */ /* first place! Also, then it */ /* will get called if a portion of */ /* the expanded area was within */ /* the updateRgn! */ FrameRoundRect(&box, 16, 16); SetPenState(&oldPen); /* restore the pen state */ SetPort(oldPort); /* and the old port */ } I use code very similar to this, including the PenState and GetPort/SetPort calls all the time. I found the SetPort necessary on my old Plus... -- =============================================================================== | Glenn L. Austin - Mac Wizard and Auto Racing Driver | | Usenet: glenn@gla-aux.uucp | | "Turn too soon, run out of room. Turn too late, much better fate." |