Jump to content
  • Advertisement
Sign in to follow this  
mike74

OpenGL windows screensaver

This topic is 4818 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I was just wondering if anyone here knows how to make a Windows screensaver. I have an OpenGL graphics program I wrote that I'd like to make into a screensaver, but I'm not sure exactly how to do it. Thanks. mike http://www.coolgroups.com/

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Rename your .exe to .scr and copy it into C:\WINDOWS\system32

Ofcourse if you wan't to support things like passwords etc, it's some more hazzle.

Share this post


Link to post
Share on other sites
One of the hard parts is getting the preview mode to work.

For a preview, Windows will call your screen saver like so:

screensaver.scr /p 88332

where 88332 is the handle of a window in which you should draw a preview.

That's fine, and I create a HWND object with that id:

if (!strncmp(lpCmdLine, "/p", 2)) hWnd = (HWND) atol(lpCmdLine+3);

Then I draw to it. The preview looks fine initially. However, my program doesn't know when to exit. I think I need to figure out when the window with id 88332 gets destroyed, but I don't think my program receives any messages pertaining to this window. Any ideas?

mike
http://www.coolgroups.com/

Share this post


Link to post
Share on other sites
Quote:
Original post by mike74
...
screensaver.scr /p 88332

where 88332 is the handle of a window in which you should draw a preview.
...


Acctaully, I'm pretty sure thats the handle of the parent window, so you should acctaully create a window that is a child window of 88332.

Share this post


Link to post
Share on other sites
Where can I find VS 2005?

Also, I think the /p argument is the parent now. So, I need to make a child window. Making a child window seems to work, but how do I know what width and height to make it? The CW_USEDEFAULT macro doesn't seem to do the job.

mike
http://www.coolgropus.com/

Share this post


Link to post
Share on other sites
Here's how I decided to determine the width and height:

HWND parent = NULL;
if (!strncmp(lpCmdLine, "/p", 2)) parent = (HWND) atol(lpCmdLine+3);


if (parent) {
RECT r;
GetWindowRect(parent, &r);
int width = r.right - r.left;
int height = r.bottom - r.top;
...
}

If you know of anything better, please let me know.

Now, the main issue is figuring out how to install the screensaver properly. I'd like to make my screensaver the default one, and I'd like to pop up the screensaver configuration box after the installation.

This program does it:
http://www.jumbo.com/file/10177.htm

So, it must be possible.

Any ideas how to do it?

Thanks.

mike
http://www.coolgroups.com/






Share this post


Link to post
Share on other sites
Here's a snippet from my Screensaver installer i used for many commercial savers (and yes, it contains ugly ini file settings, but it works this way since 95):


DWORD result;

char szShortPath[MAX_PATH];


result = GetShortPathName( m_strScreenSaverFileName.c_str(), szShortPath, 500 );

if ( ( result == 0 )
|| ( result > 500 ) )
{
// couldn't get short path
return FALSE;
}
if ( !WritePrivateProfileString( "BOOT", "SCRNSAVE.EXE", szShortPath, "system.ini" ) )
{
// Kein INI-Eintrag möglich
return false;
}
if ( !WritePrivateProfileString( "windows", "ScreenSaverActive", "1", "win.ini" ) )
{
return false;
}
SystemParametersInfo( SPI_SETSCREENSAVEACTIVE, TRUE, 0, SPIF_UPDATEINIFILE );
SystemParametersInfo( SPI_SETSCREENSAVEACTIVE, TRUE, 0, SPIF_SENDWININICHANGE );


Also, keep in mind, you can register a saver that is not in the windows system folder this way, but once the user chooses another he can't choose yours back in.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!