Click to See Complete Forum and Search --> : How to run a Screen Saver


Jeff Myers
April 29th, 1999, 12:04 PM
I have been trying to find a way to execute a screen saver. I have a program (Written in MFC) that enables or disables the current screen saver. I would like to add the capability to execute the screen saver imediately. Can some one give me some help?

Thanks,
Jeff Myers

Marc Howe
April 29th, 1999, 01:00 PM
Wow! You must be making the program I just finished making...I just finished one that allows the user to enable/disable/activate the SS and allows for rebooting/logging off Win. Also, I just figured out how to change the monitor's resolution. If you want any of this code as well, just let me know.

Well, anyway the code for activating the SS was given to me here at CodeGuru by an anonymous source...it works very well. Here you go:

CDialog dlg;
dlg.Create(IDD_LAUNCHSS_DLG);
dlg.SendMessage(WM_SYSCOMMAND, SC_SCREENSAVE);
dlg.DestroyWindow();

As long as a dialog resource exists within the application that is identified by IDD_LAUNCHSS_DLG, the user's presently defined screen saver is fired off.

I tried some other methods and they never worked...this one works extremely well. Notice there is no call to DoModal(); therefore no dialog is truly shown, it just is called so that the SendMessage routine works...I think?!

Anyway...
Good luck,
Marc

P.S. I've been working a lot w/SS routines lately, so if you need any help...I'll try.

Michael Setzer
January 31st, 2001, 06:45 AM
Is there a way to stop the Screen saver by program. For example after a sleep of 10 seconds. If there is a way does it also work with a password protected screen saver.