Logo

Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.

SAVE SCREEN, RESTORE SCREEN

These obsolete commands let you save and restore an image of any window.

Usage

SAVE SCREEN [ TO VarName ]
RESTORE SCREEN [ FROM VarName ]

Back in the days before windows or Windows, there were times when you needed to overwrite part of the screen (for example, with a confirmation message) and then be able to get back to where you were. These commands sort of let you do that. SAVE SCREEN let you make a copy of the screen image, either in a special buffer or in a variable. RESTORE SCREEN let you put the image back.

The key word in all that is “image.” The restored screen wasn’t live any more. Any @ .. GETs in it didn’t work when it was restored.

Nothing’s changed. SAVE SCREEN still saves an image, though it can work on a window rather than the background screen. RESTORE SCREEN still doesn’t make things live. However, it’s easy to fool yourself into thinking these commands are smarter than they are. When you CLEAR a Visual FoxPro form, the controls are still there, alive, even if you can’t see them. If you SAVE SCREEN a form, then CLEAR the form, then RESTORE SCREEN, it looks as though live controls have been restored. In fact, all that was restored was the image. The controls were live all along.

A word of caution: SAVE SCREEN TO creates a variable type unique unto itself—the type “S” variable. This one has some funny behaviors not seen elsewhere. An S variable cannot be passed to a routine as a parameter. While S variables in FoxPro/DOS stored two bytes per row/column cell (one for the character, one for the color), in Windows these files seem to grow enormously as they, we suspect, inefficiently store all the color characteristics for each pixel. This means that not only are the variables and files ridiculously large, they are also incompatible between platforms.

These are legacy commands. Avoid them in new code. Toggle Visible properties to make things go away and use Refresh methods to make objects redraw themselves. Stay away from this stuff.

Example

SAVE SCREEN TO sBackDrop
CLEAR
* Now display something else
CLEAR
RESTORE SCREEN FROM sBackDrop

See Also

Clear