About Screen Savers

Screen savers are Windows applications that contain specific variable declarations, exported functions and resource definitions. The MDK provides a static-link library, SCRNSAVE.LIB, that 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 the visual and/or audio effects that comprise the screen-saving activity.

A Windows application, SCRNSVR.EXE, is loaded automatically when Windows is started or when the user activates the screen-saver feature using the Screen Saver applet. Using a Windows hook, SCRNSVR.EXE monitors keystrokes and mouse movements and starts the screen saver after a period of inactivity or when the user double-clicks the desktop using the right mouse button.

SCRNSVR.EXE does not start the screen saver if any of the following conditions are present:

The currently active application is a non-Windows (MS-DOS) application.

A computer-based training (CBT) window is present.

The currently active application returns a non-zero value in response to the WM_SYSCOMMAND message sent with the SC_SCREENSAVE identifier.

Summary: Window Class Registration

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.lpfnWndProc   = ScreenSaverProc;                                                // You supply
    cls.hIcon         = LoadIcon(hInst,MAKEINTATOM(ID_APP));        // You supply
    cls.lpszClassName = szAppName;                                                                // You supply

    cls.style         = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_DBLCLKS;
    cls.hInstance     = hInst;
    cls.cbWndExtra    = 0;
    cls.cbClsExtra    = 0;
    cls.hCursor       = NULL;
    cls.lpszMenuName  = NULL;
    cls.hbrBackground = GetStockObject(BLACK_BRUSH);

Your source-code module provides the ScreenSaverProc window procedure, as well as the szAppName string variable, used as the class name for the screen-saver window. Your resource-script file supplies the ID_APP icon.