Constructing Your Screen Saver

These pages explain how to build your screen saver, including the C++ code you need and how to incorporate it into your program.


I've had enough! I want to go home

I want to see the previous page

Take me to the next page


Creating a Cut-Down MFC Framework

Your first step is to use Visual C++ to create an MFC application, but without the Document, View and Mainframe classes.

So, create a new project using "MFC App Wizard (exe)". Specify a "Win32" platform.

Use a Single Document interface, with :

Use a statically linked library for MFC, because you probably want the screen saver to be used by people who don’t have Visual C++ installed, and this saves having to distribute the MFC dll file.

In the "File View" pane, delete :

"xxx" is the project name. You can delete these files by highlighting them then pressing the Delete key.

Use "Explorer" to delete the following generated files :

Use "Class Wizard" to attempt to display the CMainFrm, CxxxDoc and CxxxView classes. It will complain that it cannot find the files, then display a dialog that will let you remove these classes. This lets you get rid of these classes.

Display the xxx.cpp source code. You will need to delete the following lines that refer to the deleted files :

Delete all the lines that occur between ‘LoadStdProfileSettings’ and ‘return TRUE’ (but not those lines themselves).

Delete the standard icons, ‘xxx.ico’ and ‘xxxDoc.ico’. You will need to remove them from the Resource Pane and the File Pane. You delete them in these panes by clicking on them to hightlight them, then pressing the 'Delete' key. Then use Explorer to delete them from your project’s ‘Res’ folder.

Create a new icon for your screen saver. You can do this by inserting a new icon resource, and giving it a suitable name.

I have found it is better to do discard the old icons and insert your new one before generating the project for the first time. When Explorer displays your screen saver file name, it shows the first icon it finds included with your file. If your icon is the only one there, it has no choice but to display your one. Otherwise, you have to give your icon a resource id number that is lower than any of the other icons.

Go to "Project/Settings", select the "Link" tab and the "General" category. Change the output file name for all configurations (i.e. Debug and Release) to :

where is suitable as a description of your screen saver. Control Panel will use the file name you enter here to describe your screen saver. Your program needs to have the ".scr" extension so that it will be recognized as a screen saver.

Build the project, to verify you've done everything correctly so far. It should compile and link cleanly.

Remove the AppAbout Dialog box. You don't need it, because your screen saver does not have a menu. You remove this by :

Use Class Wizard to delete the ‘OnAppAbout’ function for your ‘CxxxApp’ class. This will also remove the ‘CAppAbout’ class.

Display the xxx.cpp source code, and manually delete all the code that follows the ‘InitInstance’ function. You are deleting the code that applies to the ‘AppAbout’ dialog box.

Build the project. It should compile and link cleanly.

Remove unwanted resources. The following resources that get automatically generated can be deleted :

You delete these by highlighting them in the Resource Pane then pressing the Delete key.

It is nice to keep the version resource there, because you can use it to contain information to be shown when someone right clicks on your screen saver file name, and selects "Properties/Version".

Rebuild the project, to ensure it still compiles and links cleanly.


The next page shows you the code you need for the full-screen window.


Next | Previous | Home

1