screensavers

Started by
5 comments, last by Zirco 22 years, 6 months ago
hi, i''m wondering how to turn my .exe openGL program into a screensaver.
Advertisement
Heh, you could try to change the file`s extension to "scr"
try

http://www.ite.mh.se/~danli97/opengl/

havn''t checked the code at all though. A search for ''minimal.zip screensaver'' on google has a couple other suggestions.
you must change you extension from .exe to .scr and keep in the mind about the command line parameter /f /w /z /s these are regarding your settings , full screen , window etc paremeters from windows O.S.
Screen savers are programmed a little differently. Besides the extension, screen savers do not have a WinMain() function and don't need to create a message loop.

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
I followed these instructions and it stil says "initialization failed" when Windows tries to run the screensaver. What do you suggest I do? Thanks.

~Scraniel~
  // in WndProc somewherecase WM_KEYDOWN:case WM_LBUTTONDOWN:case WM_RBUTTONDOWN:case WM_MBUTTONDOWN:case WM_MOUSEMOVE:{     PostQuitMessage(0);}  


That should do it. And change the extension to .scr

This topic is closed to new replies.

Advertisement