[comp.sys.mac.programmer] Problem: getting strucRgn/contRgn of invisible windows

bin@primate.wisc.edu (Brain in Neutral) (01/27/91)

I want to do some window positioning, taking into account the
size of the window *including* the window frame - i.e., I want
to use the strucRgn and not portRect.  (Why? Well, suppose you
want to position a window so that the title bar doesn't come
under then menu bar.  Then you need to know how tall the title
bar is.)

Trouble is, the strucRgn (and contRgn) fields of invisible
windows seem to be empty.  I thought at first that it was just
a matter of the regions not being calculated until the window
was shown, but after some messing about, it appears that
the regions are set empty when windows are hidden, as well.

Any way to determine the strucRgn of an invisible window?

-- 
Paul DuBois
dubois@primate.wisc.edu

keith@Apple.COM (Keith Rollin) (01/29/91)

In article <3839@uakari.primate.wisc.edu> bin@primate.wisc.edu (Brain in Neutral) writes:
>I want to do some window positioning, taking into account the
>size of the window *including* the window frame - i.e., I want
>to use the strucRgn and not portRect.  (Why? Well, suppose you
>want to position a window so that the title bar doesn't come
>under then menu bar.  Then you need to know how tall the title
>bar is.)
>
>Trouble is, the strucRgn (and contRgn) fields of invisible
>windows seem to be empty.  I thought at first that it was just
>a matter of the regions not being calculated until the window
>was shown, but after some messing about, it appears that
>the regions are set empty when windows are hidden, as well.
>
>Any way to determine the strucRgn of an invisible window?

MacApp does this by saving off the contents of those fields, calling
the WDEF directly with the wCalcRgns message, looking at the results,
and then restoring the old contents of the fields.

I'll bet Larry Rosenstein wrote that code. We've never had to change
it...


-- 
------------------------------------------------------------------------------
Keith Rollin  ---  Apple Computer, Inc.  ---  Developer Technical Support
INTERNET: keith@apple.com
    UUCP: {decwrl, hoptoad, nsc, sun, amdahl}!apple!keith
"Argue for your Apple, and sure enough, it's yours" - Keith Rollin, Contusions

bin@primate.wisc.edu (Brain in Neutral) (01/30/91)

From article <48582@apple.Apple.COM>, by keith@Apple.COM (Keith Rollin):
| In article <3839@uakari.primate.wisc.edu> bin@primate.wisc.edu (Brain in Neutral) writes:
|>Any way to determine the strucRgn of an invisible window?
| 
| MacApp does this by saving off the contents of those fields, calling
| the WDEF directly with the wCalcRgns message, looking at the results,
| and then restoring the old contents of the fields.

Anyone have code to do this?  (Yes, I feel stupid asking this, since
the WDEF function definition is in IM, but I had already tried this
and couldn't get it to work.  THINK C preferred, but anythink accepted
gratefully.)
--
Paul DuBois
dubois@primate.wisc.edu

pbuck@tcs.com (Peter Buckner) (01/30/91)

In article <3856@uakari.primate.wisc.edu> bin@primate.wisc.edu (Brain in 
Neutral) writes:
> | MacApp does this by saving off the contents of those fields, calling
> | the WDEF directly with the wCalcRgns message, looking at the results,
> | and then restoring the old contents of the fields.
> 
> Anyone have code to do this?  (Yes, I feel stupid asking this, since
> the WDEF function definition is in IM, but I had already tried this
> and couldn't get it to work.  THINK C preferred, but anythink accepted
> gratefully.)

Hmm... If I remember right, to call an existing WDEF function, do 
something like this:

   WindowPeek wnd;
   int varCode = L;
   long param = 0L;
   int message = wCalcRgns;
   ret = CallPascalL(varCode, wnd, message, param,wnd->windowDefProc);

That should update theWindow->strucRgn & theWindow->contRgn fields.

Lawson.English@p88.f15.n300.z1.fidonet.org (Lawson English) (02/01/91)

Brain in Neutral writes in a message to All

BIN> ny way to determine the strucRgn of an invisible window


Move it off screen, show it, get the strucRgn, hide the sucker, and restore
it to it's original position.


Lawson
 

--  
Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!300!15.88!Lawson.English
Internet: Lawson.English@p88.f15.n300.z1.fidonet.org