Path: utzoo!attcan!uunet!tut.cis.ohio-state.edu!ucbvax!dewey.soe.berkeley.edu!oster From: oster@dewey.soe.berkeley.edu (David Phillip Oster) Newsgroups: comp.sys.mac.programmer Subject: Re: Finding the size of the screen under Multifinder/Color QD Message-ID: <33404@ucbvax.BERKELEY.EDU> Date: 30 Dec 89 03:41:55 GMT References: <10139@saturn.ucsc.edu> Sender: usenet@ucbvax.BERKELEY.EDU Reply-To: oster@dewey.soe.berkeley.edu.UUCP (David Phillip Oster) Organization: School of Education, UC-Berkeley Lines: 67 In article <10139@saturn.ucsc.edu> sirkm@ssyx.ucsc.edu (Greg Anderson) writes: >TN #117 says to look at the QuickDraw variable screenbits.bounds to >find the size of the screen, but on my Mac IIx, this rectangle is >always (0,0,0,0) when MultiFinder is installed (color or b&w). Tim Maroney is right, it should return the bounding rectangle of the CRT that has the menu bar. It always has for me. >First question: what _is_ a gDevice? Is there one & only one gDevice >per monitor (/other display device) hooked up to the Mac, or might there >be multiple devices referencing a single monitor? If the later, why? There should only be one at a time. Some video boards change the number of pixels they display depending on what mode they are in: i.e, they might be 640x480 in 8-bit per pixel mode, by 1024x1204 withe one bit per pixel. In addition, since graphic devices hold the inverse color table data structures (used for color matching when you do a CopyBits of a pixmap with one color table to a pixmap with a different table) there may be graphic devices that aren't connected to screens. >The reason I wish to know the size of the screen is simply to center my >dialogs on the screen. Given this purpose, should I just look at one >gDevice (namely, the one returned by GetGDevice)? Once I have this handle, >how should I determine the screen bounds? Get the PixMap from >(*gDev)->gdPMap and then look at pixMap.bounds? use screenBits.bounds. Here _is_ a use for gDevices: I redefine the zoom box, so that windows zoom to the full size of the CRT they are on, rather than Apple's default. There is nothing more annoying than working with a two-monitor system, clicking on the zoom box of a window, and have it leap to the other, smaller montior. Here is a code fragment: /* GetBiggestZoom - set r to the dimensions of the largest extern SysEnvRec world; biggdh = NIL; if(world.hasColorQD){ for(gdh = GetDeviceList(); gdh != NIL; gdh = GetNextDevice(gdh)){ if(TestDeviceAttribute(gdh, screenDevice) && TestDeviceAttribute(gdh, scrnActive)){ if(biggdh == NIL || (**gdh).gdRect.bottom - (**gdh).gdRect.top > (**biggdh).gdRect.bottom - (**biggdh).gdRect.top){ biggdh = gdh; } } } } if(biggdh == NIL){ *r = screenBits.bounds; r->top += GetMBarHeight(); }else{ *r = (**biggdh).gdRect; if(TestDeviceAttribute(biggdh, mainScrn)){ r->top += GetMBarHeight(); } } } > The mac is a detour in the inevitable march of mediocre computers. > drs@bnlux0.bnl.gov (David R. Stampf) --- David Phillip Oster -master of the ad hoc odd hack. Arpa: oster@dewey.soe.berkeley.edu Uucp: {uwvax,decvax}!ucbvax!oster%dewey.soe.berkeley.edu