[comp.sys.mac.programmer] Window Drawing Woes.

spencer@cgrg.ohio-state.edu (Stephen N. Spencer) (04/08/91)

I've got an interesting problem that I'd really like to solve, but am not
sure how to go about doing so.  It involves creating a new window and drawing
into it.  I set up my window rectangle as:

	SetRect(&bRect, 10, 40, 210, 190);

because I want a 200 by 150 pixel drawing area in my window.  I then do:

	theWindow = NewWindow(NIL, &bRect, winTitleStr, TRUE,
			      noGrowDocProc, (WindowPtr)-1L, TRUE, 0);

	SetPort(theWindow);
	ShowWindow(theWindow);

So far, so good.  The very first time I draw into this window (which happens
when I load a data file into the scene associated with this window), the
top part of the window gets nothing drawn into it.  If I move the window 
before I load the data, everything will be drawn OK.

I've got some idea of what's going on.  I am using an offscreen bitmap in 
order to help cut down unnecessary redrawing, and so on a redraw, I'm drawing
into the offscreen bitmap and doing a CopyBits() to the window.  The entire
image is in the offscreen bitmap, but it's not showing up in the window.  I 
think this is the problem:

	OSBM->portBits.bounds: 	0, 0, 200, 150  (l,t,r,b)
	OSBM->portRect:		0, 0, 200, 150
	wind->portBits.bounds:	-10, -40, 630, 440
	wind->portRect:		0, 0, 200, 150

Indeed, the top forty pixels of the image aren't displayed that first time.

Any ideas on how I can fix this?  Thanks in advance.