Sign in to follow this  

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

This topic is 4748 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
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

This topic is 4748 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this