[futurebasic] Re: [FB] Offscreen globaltolocal etc. driving me crazy

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : September 1999 : Group Archive : Group : All Groups

From: Robert Purves <robert.purves@...>
Date: Thu, 2 Sep 1999 19:17:28 +1200
>  This is what I want to do:
>1.  Get a dialog from a resource file (but don't show it).
>2.  Copy the area of the screen under the dialog to an offscreen gworld
>using the correct coordinates.
>3.  Show, process, and dispose of the dialog.
>4.  Restore the area of the screen that was under the dialog

You are proposing an interesting but narrow solution to a refresh problem,
similar to what the menu manager does when a menu is pulled down.

Consider the bigger picture. At any time (more accurately, whenevever your
program executes HANDLEEVENTS), the user may switch your program out,
clobbering any part of any or all of your windows. When your program
regains control, it should then eventually respond to the system-generated
_wndRefresh dialog event, by redrawing the affected windows (or parts
thereof). The closing of a dialog box that overlapped your window also
generates the appropriate refresh event, which can be handled in the same
way. This presupposes that the program always maintains the relevant
information to allow the window contents to be recreated.

A good method to ensure that your program works in this way is _never_ to
draw (or print, etc) directly to a window. Instead, when you want something
drawn in a window, call INVALRECT for that window, as in the example code
below, and let the refresh routines do the drawing on the next
HANDLEEVENTS. This approach requires some mental readjustment, but it
ensures that "real" refreshes will work with no further effort on your part.

LOCAL FN InvalWholeWindow(wndNum) ' force update of entire contents
 DIM wndOut,rect;8
 CALL SETRECT(rect,0,0,WINDOW(_width),WINDOW(_height))

Of course there are exceptions where this method cannot work, but they are
few. Certain animation techniques, using _srcXOR drawing or SCROLLRECT, may
make the the current window contents impossible to recreate from data.

Robert Purves