Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ames!pacbell!well!wdh From: wdh@well.UUCP (Bill Hofmann) Newsgroups: comp.sys.mac.programmer Subject: Re: Saving window position question Keywords: Window, MultiFinder Message-ID: <12616@well.UUCP> Date: 8 Jul 89 15:47:41 GMT References: <505@suna.CMI.COM> <7889@hoptoad.uucp> Reply-To: wdh@well.UUCP (Bill Hofmann) Distribution: usa Organization: Whole Earth 'Lectronic Link, Sausalito, CA Lines: 31 In article <7889@hoptoad.uucp> tim@hoptoad.UUCP (Tim Maroney) writes: >In article <505@suna.CMI.COM> maryd@suna.CMI.COM (Mary Dimercurio) writes: >>... How do I get the location of my windows to save (I plan to >>save them in a resource)?? > >You can get the size just by looking at the portRect of the window. >The position is almost as easy -- SetPort to the window and then do a >LocalToGlobal on the point (0,0). These will require a bit more work >if you have been doing SetOrigin calls, which is one of the many >reasons I never use SetOrigin. It's actually much easier than that: { Rect saveWindow; ... SetPort(myWindow); saveWindow = myWindow->portRect; LocalToGlobal(&(((Point *) &saveWindow)[0])); LocalToGlobal(&(((Point *) &saveWindow)[1])); ... } Which does a LocalToGlobal on the topLeft and the botRight of the portRect. Actually, what you probably *should* do is save the userState and stdState of the window (assuming it's a zooming window). You can get those from the dataHandle in the WindowRecord, and they're already global. Then, save a boolean which tells you which state it's in (compare the globalized portRect with one of them). Of course, when you open the document, you need to check that the current state is on one of the current screens. -Bill Hofmann