Archived

This topic is now archived and is closed to further replies.

Scraniel

Midnight Coder's screensaver code!

Recommended Posts

This informative post was posted by Midnight Coder in August. It helped me out a lot converting my OpenGL animation to a screensaver, and i followed its instructions front to back. Yet when Windows tries to run the screensaver or Preview it, it says "Initialization failed". Can you anybody tell me what that could mean? I have included all the code necessary according to Midnight Coder. Thanks. ~Scraniel~ Midnight Coder''s post: > 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 >

Share this post


Link to post
Share on other sites
I''m working on a similar Project and also got my problems... but everythings running so far... just don''t try to start the thing over the Windows Control Panel ;o))

I could send you the code.... If you still want it ;o)

Markus

Share this post


Link to post
Share on other sites
FYI: About 2 years ago I created a screen saver skeleton which implements all the necessary event handlers and also solves your windows control panel problems.

You just need to implement the Draw frame function and you''re done.


It''s available in the Projects section of CornflakeZone.

-fs

http://www.CornflakeZone.com
//-- Modelling and animation in every dimension --//

Share this post


Link to post
Share on other sites
Thanks a lot fshana. I downloaded the skeleton code. But since I am a newbie, I can''t really figure it out. I am only used to one ".cpp" file to create an animation. What are the other .h and .cpp files for? Could you please tell me where to put the code from my original OpenGL animation into the Screensaver skeleton in order to make it into a screensaver? Thanks a lot. I appreciate it.

~Scraniel~

Share this post


Link to post
Share on other sites