How Can I tell if the screensaver if currently active or not

I would like to be able to be notified (trap a message) when the screensaver becomes active on a computer, or at least be able to tell if it is active or not.
MusicBuddhaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

b_vishwajitCommented:
Hi Mr.Buddha. This question has already been discussed. Please refer to the link
http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_10152190.html
Let me know if it was helpful. You can award all the points to actual author of the answer.
0
jkrCommented:
BOOL IsScreenSaverRunning()

BOOL bRunning = FALSE;

SystemParametersInfo(SPI_GETSCREENSAVERRUNNING,0, (LPVOID)&bRunning,0);

return bRunning;
}
0
jkrCommented:
Oops, that should be

BOOL IsScreenSaverRunning() {

    BOOL bRunning = FALSE;

    SystemParametersInfo(SPI_GETSCREENSAVERRUNNING,0, (LPVOID)&bRunning,0);

    return bRunning;
}
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

MusicBuddhaAuthor Commented:
Hello again Mr Joker ?? o) is it?

Oops, that should be

That more than answers the question that I asked for me. But I was wondering if there was any way to set it up so that my app can be notified when the Screensaver gets turned off and then again when it comes on?

Thanks,

Buddha
0
i_maheshCommented:
Hi,

In the appliation message loop you can listen to the WM_SYSCOMMAND message with wParam as SC_SCREENSAVE to know when the screen saver is being invoked.

System sends this message to all the running applications just before the invocation of ScreenSaver.

0
MusicBuddhaAuthor Commented:
According to the SDK:

WM_SYSCOMMAND

A window receives this message when the user chooses a command from the Window menu
(formerly known as the system or control menu) or when the user chooses the maximize button,
minimize button, restore button, or close button.

SC_SCREENSAVE
Executes the screen saver application specified in the [boot] section of the System.ini file.

//I've setup a message map for the WM_SYSCOMMAND which should trigger
//an event if what you are saying is correct when the SS goes on or off.

BEGIN_MESSAGE_MAP
     VCL_MESSAGE_HANDLER(WM_USER+100, TMessage, OnWMUSER100)
     VCL_MESSAGE_HANDLER(WM_QUERYENDSESSION, TMessage, OnQueryEndSession)
     VCL_MESSAGE_HANDLER(WM_POWERBROADCAST, TMessage, PowerBroadCast)
     VCL_MESSAGE_HANDLER(WM_SYSCOMMAND,TMessage,  SysCommand)
END_MESSAGE_MAP(TForm)
  void __fastcall SysCommand(TMessage & Msg);


//In effect I should be seeing this process "SysCommand" being triggered whenever
//there is a Screen Saver (SS) on off event but I seee nothing
// it does trigger if I use the system menu of the application like the SDK says. But not on the the SS :(

void __fastcall TForm1::SysCommand(TMessage & Msg)
{
ShowMessage(Msg.WParam);
ShowMessage("HURRAH!");
}



0
MusicBuddhaAuthor Commented:
i_mahesh

>>In the appliation message loop you can listen to the WM_SYSCOMMAND message
>>with wParam as SC_SCREENSAVE to know when the screen saver is being invoked.

Any chance you could give me an example of how to do this, I would be hapopy to set it up  as a 250 point question. I am happy to get an example in C/C++ but I am using CBuilder 5 so if you have experience with that, it would be even better.

Thanks,

Buddha
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.