Jump to content
  • Advertisement
Sign in to follow this  
Aprosenf

How can my program know when the screen saver is activated or deactivated?

This topic is 4966 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 basically have a program that sits in the background (using a tray icon), and I want it to do stuff whenever the screen saver is activated or deactivated. How do I go about doing this? Does Windows send a message to every top-level window when that happens? What message? I can't seem to find anything very helpful on MSDN.

Share this post


Link to post
Share on other sites
Advertisement
"Before Windows starts the screensaver, it broadcasts a WM_SYSCOMMAND message with WPARAM set to SC_SCREENSAVE. If any program catches the message and returns true, the screensaver will not start."

Share this post


Link to post
Share on other sites
I'm not sure that event can be trapped in a simple way.
But you can determine if a screensaver is running with SystemParametersInfo(), specifying SPI_GETSCREENSAVERRUNNING (Google for this). Perhaps you can set an interval that checks for this condition.
Good luck.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You may be able to set a boolean when the screen saver is running, and then use something like the following (from a C++Builder program, so modify accordingly):


void __fastcall TForm1::WndProc(TMessage & msg) {
if (msg.Msg==WM_ACTIVATEAPP && msg.WParam==TRUE && screenSaverRunningC) {
//do whatever...
screenSaverRunningC = false;
}

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!