<h1>FAQs</h1><h2>Why is my window erased as soon as I draw into it? [OS 9]</h2><p>You should never draw into a window until you have received an update event. Heres an explanation of how the Mac handles updates and why you should react at the proper time:</p>
<p>When a window is built or brought forward, most often all or part of its content must be refreshed. The window manager collects these clobbered areas in a structure called an update region (sometimes called the clobbered region). You can force pieces of a window to be added to this region by calling <span class="pre">FN INVALRECT</span>, and force pieces to be subtracted from the region by calling <span class="pre">CALL VALIDRECT</span>.</p>
<p>When nothing else is going on in MacDom, the Window Manager looks around to see what needs to be fixed and sees that it has an update region for your window. It builds a fake event (<span class="pre">_updatEvt</span>) and sends it through the event queue.</p>
<p>FutureBASIC sees the update event and calls <span class="pre">BEGINUPDATE</span>. This swaps the visible region with the clobbered region. FB then erases the clobbered area, redraws all controls and fields, then calls your program to do its drawing via the <span class="pre">_updatEvt</span>. When your program receives the <span class="pre">_updatEvt</span> event, you are expected to draw the windows contents. When everything is finished, FB calls <span class="pre">ENDUPDATE</span> to reset all regions back to normal.</p>
<p>Remember: anytime a window is built, the Window Manager automatically sends you an update event - without fail. You can count on it.</p>
<p>If you draw into a window when it is first built or when some button is clicked or a menu item is selected, rather than in response to an update event, the update sequence will erase your work; and after the update you'll be looking at a blank window.</p>
<p>Always do your drawing in response to update events.</p>
<pre>
// build file menu
MENU 1,0,1,"File"
MENU 1,1,1,"Quit/Q"
// set up constants for windows
_circleWnd = 1
_squareWnd = 2
// dialog handler -- this is where update events are handled