[comp.sys.mac.programmer] Region Manipulation

sanjay@gt-cmmsr.GATECH.EDU (Sanjay Vasandani) (09/25/88)

I have a question regarding manipulation of regions.

Whenever I use the procedure CopyRgn(CurrentRegion,Region1) and then try to 
alter CurrentRegion it seems to alter Region1 also on its own contrary to 
what is written in Inside Macintosh Vol1. which says that after using the 
CopyRgn function, the source region can be altered without affecting the
destination region.

For example if I use SetEmptyRgn(CurrentRegion) it destroys Region1 also and if 
instead of destroying CurrentRegion I assign a new shape to it and then use 
CopyRgn(CurrentRegion,Region2), then any subsequent action on  Region1 
such as Dragging Regions etc affects Region2 only probably because Region1
has also automatically got changed to Region2.

What I actually want is that a new shape should get assigned to CurrentRegion
and later it should permanently get stored in the from of Region1, Region2,
Region3 etc whenever the user interacting with my program so desires.

If anybody has any clue to what is going wrong or knows of a way to get 
around this problem I would be grateful if he could send me email at the 
following address:
	sanjay@cmmsr.gatech.edu
Thanks in advance.

-Sanjay
-- 
Sanjay Vasandani

UUCP:	sanjay@gt-cmmsr.UUCP
        ...!{akgua,allegra,hplabs,ihnp4,seismo,ulysses}!gatech!gt-cmmsr!sanjay
INTERNET:	sanjay@cmmsr.gatech.edu

usenet@cps3xx.UUCP (Usenet file owner) (09/26/88)

  CopyRgn doesn't create a new region; both regions must have been
created earlier.  My quick guess is that your code looks something
like:

	a := NewRgn();
	b := a;
	/* set up the A region */
	CopyRgn(a, b);

  What you really need to do is:

	a := NewRgn();	/* Create a new region */
	b := NewRgn();	/* Another new region */
	/* do stuff to A here */
	CopyRgn(a, b);	/* This puts a copy of A in B. */

  (I tried to E-mail this but it bounced.)

+----------------------------------+------------------------+
| Anton Rang (grad student)	   | "VMS forever!"	    |
| Michigan State University	   | rang@cpswh.cps.msu.edu |
+----------------------------------+------------------------+