Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!usc!ucsd!helios.ee.lbl.gov!ux1.lbl.gov!beard From: beard@ux1.lbl.gov (Patrick C Beard) Newsgroups: comp.sys.mac.programmer Subject: Re: Finding the size of the screen under Multifinder/Color QD Message-ID: <4594@helios.ee.lbl.gov> Date: 9 Jan 90 15:55:54 GMT References: <10139@saturn.ucsc.edu> <9429@hoptoad.uucp> <1102@urbana.mcd.mot.com> <10164@saturn.ucsc.edu> <9490@hoptoad.uucp> <1990Jan5.234652.4485@santra.uucp> <9530@hoptoad.uucp> Sender: usenet@helios.ee.lbl.gov Reply-To: beard@ux1.lbl.gov (Patrick C Beard) Organization: Lawrence Berkeley Laboratory, Berkeley Lines: 44 X-Local-Date: 9 Jan 90 07:55:54 PST In article <9530@hoptoad.uucp> tim@hoptoad.UUCP (Tim Maroney) writes: # #Nope. The OpenPort strategy doesn't work on color systems, at least #not in the simple way you seem to be suggesting. If you just look at #port.portBits.bounds, you'll be looking at something weird (a handle #followed by two integers) on color systems. # # if ((port->portBits.rowBytes & 0x8000) == 0) # screen = port->portBits.bounds; # else { PixMapHandle pm = ((CGrafPtr) port)->portPixMap; # screen = (*pm)->bounds; # } I've used the OpenPort strategy before and it does work. In fact, if you just open a classic GrafPort, you don't need to go through the tests you show above. I have also just used the portRect field of the GrafPort to give me the same information: ScreenSize(Rect *r) { GrafPort aPort; OpenPort(&aPort); *r = aPort.portRect; ClosePort(&aPort); } Another method is to just use the Window Manager port. Instead of the OpenPort call above, and instead of allocating a GrafPort on the stack you only need a GrafPtr. ScreenSize(Rect *r) { GrafPtr aPort; GetWMgrPort(&aPort); *r = aPort->portRect; } This seems to work on all systems I've tried. ------------------------------------------------------------------------------- - Patrick Beard, Macintosh Programmer (beard@lbl.gov) - - Berkeley Systems, Inc. "..............Good day!" - Paul Harvey - -------------------------------------------------------------------------------