Screen savers are Windows applications that contain specific variable declarations, exported functions, and resource definitions. The static-link library SCRNSAVE.LIB contains the WinMain function and other startup code required for a screen saver. To create a screen saver, you create a source module containing specific function and variable definitions and link it with SCRNSAVE.LIB. Your screen saver module is responsible only for configuring itself and for providing visual effects.
Screen savers are loaded automatically when Windows starts or when a user activates the screen saver feature by using Control Panel. Windows monitors keystrokes and mouse movements and starts the screen saver after a period of inactivity specified by the user.
Windows does not start the screen saver if any of the following conditions exists:
The active application is not a Windows application.
A computer-based training (CBT) window is present.
The active application returns a nonzero value in response to the WM_SYSCOMMAND message sent with the SC_SCREENSAVE identifier.
When your screen saver starts, the startup code in SCRNSAVE.LIB creates a full-screen window. The window class for the screen saver window is declared as follows:
WNDCLASS
cls; cls.hCursor = NULL; cls.hIcon = LoadIcon(hInst, MAKEINTATOM(ID_APP)); cls.lpszMenuName = NULL; cls.lpszClassName = "WindowsScreenSaverClass"; cls.hbrBackground = GetStockObject(BLACK_BRUSH); cls.hInstance = hInst; cls.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_DBLCLKS; cls.lpfnWndProc = ScreenSaverProc; cls.cbWndExtra = 0; cls.cbClsExtra = 0;
Your source module provides the ScreenSaverProc window procedure. Your resource-definition file supplies the icon identified by ID_APP. This icon is visible only when your screen saver is run as a stand-alone application. (To be run by Control Panel, a screen saver must have the .SCR filename extension; to be run as a stand-alone application, it must have the .EXE filename extension.)