14.2.2 Providing a Configuration Routine

When the user chooses the Setup button, Windows uses the /c or -c command-line option to start the screen saver. To start the screen saver without displaying the configuration dialog box, Windows uses the /s or -s command-line option. When no command-line option is used, Windows displays the configuration dialog box, just as if /c had been specified.

If your screen saver supports configuration by the user, your source module must provide the following functions and dialog box resource to handle configuration:

Name Description

ScreenSaverConfigureDialog Dialog box procedure for a configuration dialog box.
RegisterDialogClasses Function that registers any special or nonstandard window classes needed for a configuration dialog box.
DLG_SCRNSAVECONFIGURE Dialog box template for a configuration dialog box.

When Windows starts your screen saver with the configuration option (/c), the WinMain function in SCRNSAVE.LIB calls the RegisterDialogClasses function and then displays the configuration dialog box.

Define the ScreenSaverConfigureDialog function as you would any dialog box procedure.

Your screen saver should save its configuration settings in the CONTROL.INI file. SCRNSAVE.LIB uses the application name stored in the idsAppName STRINGTABLE statement as the CONTROL.INI application heading. Your application can use the LoadString function to retrieve the name of the heading from CONTROL.INI and then use the WritePrivateProfileString and WritePrivateProfileInt functions to store the configuration information.

The hInst parameter of the RegisterDialogClasses function contains the instance handle for the screen saver. This is the same value contained in the hMainInstance global variable. If your configuration routine does not require any special window classes, your RegisterDialogClasses function can simply return TRUE.