Members - Reputation: 122
Posted 20 August 2001 - 05:07 PM
To create a screen saver, you must include SCRNSAVE.H and you must include SCRNSAVE.LIB in your libraries when linking.
A screen saver must have a ScreenSaverProc() function, which is the screen saver's window procedure. It is passed messages like a normal window. However, for default message processing, a screen saver should call DefScreenSaverProc() instead of DefWindowProc(). ScreenSaverProc() has the following prototype:
LRESULT WINAPI ScreenSaverProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam);
You must also have a ScreenSaverConfigureDialog(). This function can be empty, but if you want to allow your screen saver to be configurable (from within the Windows display settings), then you must open a dialog in this function to allow configuration. This function is basically called when the user clicks the Settings button in the Windows display properties control panel when your screen saver is selected. ScreenSaverConfigureDialog() has the following prototype:
BOOL WINAPI ScreenSaverConfigureDialog(HWND hdWnd, UINT message, WPARAM wParam, LPARAM lParam);
Finally, your screen saver must supply a RegisterDialogClasses() function. This function is used to register custom window classes. If you don't need custom windows classes, just leave this function empty and return nonzero. RegisterDialogClasses() has the following prototype:
BOOL WINAPI RegisterDialogClasses(HANDLE hInst);
In addition to that, all screen savers must have two resources: an icon and a string. The icon must have the ID "ID_APP". The string must have the ID "IDS_DESCRIPTION" and be no more than 24 characters long, and must contain the name or description of the screen saver. This is what will show up inside the list of screen savers inside the display properties control panel (your screen saver must be in the WINDOWS\SYSTEM folder to show up though).
To convert a game to a screen saver isn't much work, you just have to change the initialization a little.
I also must mention, that to get the instance handle of your screen saver, use the hMainInstance variable (defined in scrnsave.h).
In addition to what I said, you must change the extension to .SCR
I hope I have helped. Let me know if you have questions.
Edited by - Midnight Coder on August 20, 2001 12:11:53 AM