View Full Version : Screen saver backbone?
01-16-2002, 12:45 PM
Where can I get the source code of the backbone of a WIN32 screensaver? Meaning, all the mumbo jumbo is already there and I can just stick my Opengl code in.
01-18-2002, 01:47 PM
The backbone code for a screensaver comes shipped with VC. A screensaver is only a .exe file that is renamed to .scr. The main function and the window creation code is in the scrnsave.lib
You only have to write three functions:
1) ScreenSaverProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
2) ScreenSaverConfigureDialog(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam);
3) RegisterDialogClasses(HANDLE hInstance);
Then write a .def file to export two of them:
and link your project with scrnsave.lib. You will also need scrnsave.h in your source files.
ScreenSaverProc will be the window procedure of the window with your screensaver running. You don't need to create it, you only have to set the pixelformat on WM_CREATE. ScreenSaverConfigure will be the dialog procedure of the configure dialog. You have to include your dialog using the id DLG_SCRNSAVECONFIGURE (defined in scrnsave.h).
The RegisterDialogClasses gets called once when the screensaver gets loaded, no matter if its for screen saving or for configuring it.
If you aren't completely sure how to write window procedures, look at the NeHe windows framecode. Just remove the window creation code and put the rest of the initialisation into the WM_CREATE message handler. You don't have a main(...) function with screensavers.
I hope that helps
[This message has been edited by Overmind (edited 01-18-2002).]
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.