[futurebasic] Re: How can I get the window size before build it.

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : March 1998 : Group Archive : Group : All Groups

From: Mars Saxman <marssaxman@...>
Date: Sat, 7 Mar 98 15:40:39 -0800
>My calendar app records the window location and it relocates to fit the 
>main window when it's next starting up. It just do the substract fixed 
>window size of MacOS 8's _doc type from screen size. So it doesn't work 
>on System 7, and so on.
>
>Do you have any idea? Thank you.

There is a convoluted and fairly awkward way to do this. The window's 
outside frame is stored in the window's strucRgn&. This is a region 
handle, expressed in global coordinates, which lives in the window 
record. Grab this region's bounding box and you have the window's outside 
dimensions.

The tricky part is going the other way. You have to build the window 
invisibly first, so that it has a structure region, then do this:

1) Get the new window's structure region's bounding box
2) Get the window's portRect
3) Convert the portRect into global coordinates
4) Subtract as necessary to get the width of the window's border
5) Inset the saved bounding-box frame until it sits where you want it
6) Add the border width values to the new bounding-box frame to get the 
new inner frame
7) Set the new inner frame as the window's contents.

-Mars