Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!cs.utexas.edu!samsung!think!eplunix!das From: das@eplunix.UUCP (David Steffens) Newsgroups: comp.sys.mac.programmer Subject: question about QuickDraw regions Keywords: QuickDraw regions CloseRgn Message-ID: <850@eplunix.UUCP> Date: 28 Feb 90 22:17:40 GMT Organization: Eaton-Peabody Lab, Boston, MA Lines: 50 My question concerns proper use of the QuickDraw CloseRgn call. According to my reading of _Inside Macintosh_ Volume I, pages 181-183, the following Pascal program fragment should always work correctly: RH:RgnHandle; for i:=1 to 100 do begin RH:=NewRgn; OpenRgn; { draw something } CloseRgn(RH); { do something with the region } DisposeRgn(RH) end The description of SetEmptyRgn on page I-183 seems to imply that the same function can be performed with one less call in the loop: RH:RgnHandle; RH:=NewRgn; for i:=1 to 100 do begin SetEmptyRgn(RH); OpenRgn; { draw something } CloseRgn(RH); { do something with the region } end; DisposeRgn(RH) Depending how the description of CloseRgn is interpreted, however, it seems reasonable to conclude that old region data, if any, is first thrown away before the new region data is installed. If true, the call to SetEmptyRgn seems unnecessary, and the number of calls in the loop can be minimized while still maintaining correct behavior: RH:RgnHandle; RH:=NewRgn; for i:=1 to 100 do begin OpenRgn; { draw something } CloseRgn(RH); { do something with the region } end; DisposeRgn(RH) I'm not loooking for an answer like: "Yeah, I tried it and it works." I already did, and it does. The real question here is -- can I afford to bet the farm on it _always_ working? Can anyone provide a definitive answer? -- {harvard,mit-eddie,think}!eplunix!das David Allan Steffens 243 Charles St., Boston, MA 02114 Eaton-Peabody Laboratory (617) 573-3748 (1400-1900h EST) Mass. Eye & Ear Infirmary