Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!pasteur!eris!korn
From: korn@eris.berkeley.edu (Peter "Arrgh" Korn)
Newsgroups: comp.sys.mac.programmer
Subject: Re: Screen bounds
Message-ID: <5842@pasteur.Berkeley.EDU>
Date: 21 Sep 88 04:23:14 GMT
References:  <370@husc6.harvard.edu> <2461@rti.UUCP>
Sender: news@pasteur.Berkeley.EDU
Organization: What, me organized???
Lines: 35


What I do in GLA 1.6a2 (a new release of GLA is on it's way folks), is
get the horizontal and vertical values of the upper left of the window
and stuff that into a rect "dummyRect" (currently the window is of
fixed size; that'll change soon).  Once that is done, I simple check
to see if that rect is inside the region "GrayRgn", which is defined
in all systems after 4.2 I believe (and certainly in 6.0).  This is
described in Inside Mac vol. V, and is a region containing the union of
all of the monitors connected to the system minus the menubar.

If no points of the rect are inside GrayRgn, I set default coords.  Code
is included below.


  SetRect (&dummyRect, (int) **windowPoshHandle, (int) **windowPosvHandle,
	(int) **windowPoshHandle + 40, (int) **windowPosvHandle + 50);

  if (!RectInRgn(&dummyRect, GrayRgn)) {
    **windowPoshHandle = (int) ((screenBits.Bounds.right - screenBits.Bounds.left)/2);
    **windowPosvHandle = (int) ((screenBits.Bounds.bottom - screenBits.Bounds.top)/2);


Note that I'm not setting the window to be in the dead center of the main
window (though close, because of the use of screenBits.Bounds which is only
defined for the window with the menubar on it), but that's just 'cause this
alpha version of GLA is an alpha version and I'm lazy...


Hope this helps,

Peter
--
Peter "Arrgh" Korn
korn@ucbvax.Berkeley.EDU
{decvax,hplabs,sdcsvax,ulysses,usenix}!ucbvax!korn