?
Solved

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

Posted on 2006-04-18
7
Medium Priority
?
518 Views
Last Modified: 2010-05-18
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.
0
Comment
Question by:MusicBuddha
7 Comments
 
LVL 5

Expert Comment

by:b_vishwajit
ID: 16484122
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
 
LVL 86

Expert Comment

by:jkr
ID: 16484156
BOOL IsScreenSaverRunning()

BOOL bRunning = FALSE;

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

return bRunning;
}
0
 
LVL 86

Accepted Solution

by:
jkr earned 375 total points
ID: 16484158
Oops, that should be

BOOL IsScreenSaverRunning() {

    BOOL bRunning = FALSE;

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

    return bRunning;
}
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:MusicBuddha
ID: 16484687
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
 
LVL 1

Expert Comment

by:i_mahesh
ID: 16484991
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
 

Author Comment

by:MusicBuddha
ID: 16485232
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
 

Author Comment

by:MusicBuddha
ID: 16521214
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

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question