[an error occurred while processing this directive] Node:Graphics and Windows, Next:, Previous:Direct access, Up:Graphics

10.3 Graphics screen restoring under Windows

Q: When I switch away from my DJGPP program under Windows 3.X, then switch back to it, graphics mode is down, or my screen is all messed up. Why?

Q: I cannot run my program which uses Allegro: Windows 9X says the program would work better in DOS Mode....

Q: When running a program that uses Allegro under Windows, I cannot switch away from it with Alt-<TAB>: instead of switching, the PC beeps at me.

A: Windows 3.X only saves the VGA screen in standard VGA modes (1..13h) when you task-switch away from a DOS application. In any other mode it only saves/restores the video mode number, but not the actual screen contents. Your application is most likely still in the proper video mode (if not, it's probably the fault of the Windows driver for your SVGA card), but the video memory is messed up. The beauty of all this is that your program has no way of knowing that the screen has been taken away and then returned to it.

The only reasonable thing to do is to dedicate a "hotkey" in your application (e.g., Alt-R) whose action is to redraw the entire screen. If you do that, it's best to start all the way from the beginning, e.g. with a call to GrSetMode (if you use GRX), as there are a few bad Windows video drivers which do not restore SVGA graphics modes properly upon the switch back.

Windows 9X does save and restore the SVGA state, but only if you task-switch with the Alt-<TAB> key. If the switch happens because of anything else, like a window popping up, or you pressing the Start button, there's nothing your application can do to ensure it restores correctly, because it just never gets moved back into focus. As soon as the user tries to restore it, Windows 9X comes up with this message:

 This application cannot be restored and will be terminated.

If you cannot switch from a graphics program by pressing Alt-<TAB>, it usually means that some of the Windows drivers, most likely the graphics one, is faulty. Some SVGA drivers simply don't bother to implement the save- and restore-state functions which Windows needs to switch from a DOS program that uses SVGA graphics modes. The solution is to upgrade your driver, or replace the SVGA with one that is better supported.

To prevent Windows 9X from getting in your way when running graphics programs, like popping up messages that suggest to run the program in DOS Mode, just disable one or more of the relevant properties for that program. Here's a detailed procedure to disable them all:

Programs which use latest versions of Allegro should not usually trigger warning messages from Windows, so upgrade to the latest Allegro version if you keep getting such warnings.

[an error occurred while processing this directive]