Re: Screen Savers - Module Description

new topic     » goto parent     » topic index » view thread      » older message » newer message

Here's the information I have on screen savers. It's not clear how
Win32 checks for the required Description String. Euphoria does not
currently give good support for resource tables. I suppose that you
could embed the information, or create it dynamically.

Anyway, this is what the Win32 Programmer's reference has to say:

--- START OF TEXT --------------------------------------------------------------
------------

The Desktop application in Windows Control Panel lets users select from a
list of screen savers, specify how much time should elapse before the screen
saver is started, configure screen savers, and preview screen savers. Screen
savers are loaded automatically when Windows starts or when a user activates
the screen saver feature by using Control Panel.

Once a screen saver is chosen, Windows monitors keystrokes and mouse movements,
starting the screen saver after a period of inactivity. However, Windows does
not start the screen saver if any of the following conditions exist:

.       The active application is not a Windows-based application.
.       A computer-based training (CBT) window is present.
.       The active application receives the WM_SYSCOMMAND message with wParam
set to t
he
      SC_SCREENSAVE value, but does not pass the message to the DefWindowProc fu
nction.

Screen savers contain specific exported functions, resource definitions, and var
iable
declarations. The static-link library SCRNSAVE.LIB contains the main function an
d
other startup code required for a screen saver. When a screen saver starts, the
startup code in SCRNSAVE.LIB creates a full-screen window. The window class for
this 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    = (WNDPROC) ScreenSaverProc;
cls.cbWndExtra     = 0;
cls.cbClsExtra     = 0;


To create a screen saver, most developers create a source-code module containing
three required functions and link them with SCRNSAVE.LIB. A screen saver module
is responsible only for configuring itself and for providing visual effects.

One of the three required functions in a screen saver module is ScreenSaverProc.
This function processes specific messages and passes any unprocessed messages
back to SCRNSAVE.LIB. Following are some of the typical messages processed by
ScreenSaverProc.

Message          Meaning
------------     ---------------------------------------------------------------
---
WM_CREATE        Retrieve any initialization data from the file REGEDIT.INI. Set
 a
                 window timer for the screen saver window. Perform any other req
uired
                 initialization.

WM_ERASEBKGND    Erase the screen saver window and prepare for subsequent drawin
g operations.

WM_TIMER         Perform drawing operations.

WM_DESTROY       Destroy the timer(s) created when the application processed the
 WM_CREATE
                 message. Perform any additional required cleanup.

ScreenSaverProc passes unprocessed messages to SCRNSAVE.LIB by calling the
DefScreenSaverProc function. The following table describes how this function pro
cesses
various messages.

Message      Action
------------     ---------------------------------------------------------------
---
WM_SETCURSOR     Sets the cursor to the null cursor, removing it from the screen
.
WM_PAINT         Paints the screen background.
WM_LBUTTONDOWN   Terminates the screen saver.
WM_MBUTTONDOWN   Terminates the screen saver.
WM_RBUTTONDOWN   Terminates the screen saver.
WM_KEYDOWN       Terminates the screen saver.
WM_MOUSEMOVE     Terminates the screen saver.
WM_ACTIVATE      If wParam is FALSE, terminates the screen saver.

The second required function in a screen saver module is ScreenSaverConfigureDia
log.
This function displays a dialog box that enables the user to configure the scree
n saver.
(Thus, an application must provide a corresponding dialog box template.) Windows
displays the configuration dialog box when the user chooses the Setup button in
the
Screen Saver box in the Desktop application in Control Panel. The data entered b
y the
user with the configuration dialog box is stored in the REGEDIT.INI file.

The third required function in a screen saver module is RegisterDialogClasses. T
his
function must be called by all screen saver applications. However, applications
that
do not require special windows or custom controls in the configuration dialog bo
x can
simply return TRUE. Applications requiring custom controls or special windows sh
ould
use this function to register the corresponding window classes.

In addition to creating a module that supports the three functions just describe
d, a
screen saver should supply an icon. This icon is visible only when the screen sa
ver
is run as a standalone application. (To be run by Control Panel, a screen saver
must
have the .SCR filename extension; to be run as a standalone application, it must
 have
the .EXE filename extension.) The icon must be identified in the screen saver's
resource
file by the constant ID_APP, which is defined in the header file SCRNSAVE.H.

One final requirement is a screen saver description string. The resource file fo
r a
screen saver must contain a descriptive string that Control Panel displays as th
e
screen saver name. The description string must be the first string in the resour
ce
file's string table (identified with the ordinal value 1).

--- END OF TEXT ----------------------------------------------------------------
----------

-- David Cuny

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu