Creating Screen Savers Using MSVC ++Page 3 |
This page discusses the various windows and dialog boxes that a screen saver displays.
I've had enough! I want to go home
I want to see the previous page
The Full-Screen Window is used when your screen saver is running as a screen saver (including when the 'Preview' button is clicked in the Control Panel's "Display Properties" screen saver window).
To run your screen saver with a full-screen window, you should use a borderless,
captionless window that fills the entire screen, and is placed on top of
all other windows. This is done by creating the window using the window styles
:
and specifying the size to be :
The 'GetSystemMetrics' API call retrieves various system attributes, in this case the current screen width and screen height.
You can omit all the usual window class styles, because of the special nature of the screen saver window. For example, CS_HREDRAW and CS_VREDRAW are not needed because the window is never resized, and CS_DBLCLKS is not needed because it terminates as soon as it gets the first mouse click.
The Preview Window is the small window that is shown in the picture of a monitor screen within Control Panel's "Display Properties" screen saver window.
Windows requests the preview window to be displayed by starting your screen
saver program with the "/p
The preview window should be created as a borderless, captionless child of
the window that covers the screen area of the small monitor shown in the
Control Panel window. It should be the same size as its parent window, i.e.
the window covering the picture in the small monitor screen.
The parent’s window handle (
The handle can then be specified as the parent window, and used to get the
preview window’s size (using the ‘GetClientRect’ API).
The window styles for the preview window should be :
It does not need any window class styles, because it cannot be resized and
is not expected to respond to any user input.
The preview window will get closed when :
The preview window will be requested when :
Note that the preview screen is closed then requested again when the buttons
are clicked. If your preview screen uses a long animation sequence, it may
pay to save the current status in the registry somewhere so that it can continue
when reopened. Without this, the sequence will start again from the initial
state. This probably isn't a problem for most screen savers.
The preview window must be a child window, so that it will get closed at
the proper times.
The configuration dialog box is displayed when the "Settings" button is clicked
in the Control Panel's "Display Properties" screen saver window, or if requested
from the pop-up menu displayed when right-clicking the screen saver file
name.
Windows requests your program to display the configuration dialog box by
using the "/c" or "/c:
When requested by Windows NT Control Panel, "
When requested by Windows 95 Control Panel, no window handle is supplied.
The "GetForegroundWindow" API should be used to get the window handle, and
the configuration dialog box created as a child of that window.
When requested from the pop-up menu, the configuration window should be created
and displayed as a modal dialog box that is a child of the current foreground
window.
If there are values that can be changed, they should be stored in the registry,
so that your screen saver can access them when it starts in full-screen mode,
as explained on the previous page.
The "password change" dialog box is displayed when the "Change Password"
button is clicked in Control Panel's "Display Properties" screen saver window.
With Windows 95, your program is requested to display the "Change Password"
dialog box using the "/a
"
Your screen saver should use the "standard" password changing dialog box,
which can be accessed using the "PwdChangePasswordA" function in the "MPR.DLL"
file. Fortunately, this function has a parameter that allows the parent window
handle to be specified, so that the dialog box can be created properly.
The "request password" dialog box is displayed when screen saver password
protection is turned on, and your screen saver detects user input. The screen
saver should not terminate until the password has been correctly entered.
When user input is detected, your screen saver should check whether password
protection is turned on, then display a dialog box to request the password.
This only applies to Windows 95, because NT manages the screen saver password
protection all by itself.
Your screen saver should use the "standard" password request dialog box,
which can be accessed using the "VerifyScreenSavePwd" function in the
"PASSWORD.CPL" file. This function displays the dialog box, and returns TRUE
if a correct password was entered, or FALSE if the dialog box was closed
without a password being entered. If an invalid password is entered,
"VerifyScreenSavePwd" displays an error dialog box and requests the password
again.
As explained previously, you will want to use the "SystemParametersInfo"
API to turn the SPI_SCREENSAVERRUNNING parameter on while the dialog box
is being displayed. This prevents users being able to use Alt-Tab or
Ctrl-Alt-Del. You will also want to display the cursor while the dialog box
is being displayed. This can be done using the "ShowCursor" API.
Note that when the password request dialog box is displayed, the main screen
saver window loses the input focus, and is sent a "WM_ACTIVATEAPP( FALSE
)" message. Screen savers should detect this message, and normally use it
as a signal to terminate. Mostly, terminating is the correct action, but
when the password request dialog box is being displayed, this message
should be ignored, and the screen saver should not terminate. The easiest
way to do this is to use a class variable that gets set to ‘true’
while the "password change" dialog box is being displayed, and to test this
variable when the "WM_ACTIVATEAPP" message is received. You'll see how to
this in the pages that show how to construct your code.
You should also make sure that your screen saver repaints the area under
the dialog box when it is closed or moved, because the screen saver keeps
being displayed behind the dialog box. Closing or moving the dialog box will
generate "WM_PAINT" messages, so the easiest way to handle this is to include
code for the paint requests. You might not have to do this if your screen
saver is continuously refreshing its window on a short timer loop.
Repainting the screen saver window is only an issue with Windows 95, because
NT stops your screen saver and reverts back to your desktop wallpaper when
it shows its "request password" dialog box.
Configuration Dialog Box
Password Change Dialog Box
Request Password Dialog Box