Quick question

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jul 2008
Posts: 111
Reputation: clutchkiller is an unknown quantity at this point 
Solved Threads: 1
clutchkiller's Avatar
clutchkiller clutchkiller is offline Offline
Junior Poster

Quick question

 
0
  #1
Jan 2nd, 2009
Could anyone inform me of how I would call the screen saver on windows xp?

Edit: Just did some research on MSDN and found the WM_SYSCOMMAND, and i see something about calling the screen saver in there, but i am confused on how to use it. Any help? Thanks guys
Last edited by clutchkiller; Jan 2nd, 2009 at 3:55 pm.
>That confuses me =(
Get used to it. Good programmers are in a constant state of confusion.
>Looks like i have some quasi specifics to investigate! Up Up And AWAY!
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 1,859
Reputation: twomers has a spectacular aura about twomers has a spectacular aura about twomers has a spectacular aura about 
Solved Threads: 55
twomers's Avatar
twomers twomers is offline Offline
Posting Virtuoso

Re: Quick question

 
0
  #2
Jan 2nd, 2009
Leave the computer idle until it's automatically put on.

Didn't look closely at this but it looks like it might be useful. http://www.dreamincode.net/forums/showtopic17214.htm
Last edited by twomers; Jan 2nd, 2009 at 3:56 pm.
I blag!?
"Mr Kitty, you have to live in the attic now. Here, write a diary."
I am the Walrus!
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 111
Reputation: clutchkiller is an unknown quantity at this point 
Solved Threads: 1
clutchkiller's Avatar
clutchkiller clutchkiller is offline Offline
Junior Poster

Re: Quick question

 
0
  #3
Jan 2nd, 2009
i mean using c++ and making an app out of it lol.

Edit: I dont want to create a screen saver, but call

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

Im just confused on how to use it. Thanks
Last edited by clutchkiller; Jan 2nd, 2009 at 4:07 pm.
>That confuses me =(
Get used to it. Good programmers are in a constant state of confusion.
>Looks like i have some quasi specifics to investigate! Up Up And AWAY!
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Quick question

 
0
  #4
Jan 2nd, 2009
  1. #include <windows.h>
  2. #include <iostream>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. SendMessage(GetDesktopWindow(), WM_SYSCOMMAND, SC_SCREENSAVE, 0);
  9. return 0;
  10. }
Last edited by Comatose; Jan 2nd, 2009 at 7:08 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 111
Reputation: clutchkiller is an unknown quantity at this point 
Solved Threads: 1
clutchkiller's Avatar
clutchkiller clutchkiller is offline Offline
Junior Poster

Re: Quick question

 
0
  #5
Jan 2nd, 2009
thx alot comatose, that works, but can u explain it to me? Also, say i wanted to allow the user to set a password to use on resume each time the app was run, any suggestions? I dont know much about win programming. Thanks!
Last edited by clutchkiller; Jan 2nd, 2009 at 9:37 pm.
>That confuses me =(
Get used to it. Good programmers are in a constant state of confusion.
>Looks like i have some quasi specifics to investigate! Up Up And AWAY!
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Quick question

 
1
  #6
Jan 2nd, 2009
sure, windows.h includes everything that we need. The standard C++ stuff, is just the includes, using namespaces (the namespaces and the #include <iostream> isn't even needed...it just came with the Code::Blocks IDE Blank Project, so I just left it) . So, Basically, the include directive tells the pre-compiler that we want to copy the contents of <windows.h> into our file at the top. The next step is the main function, known as the exe's entry point (the first piece of code that will run when the OS launches it) The only real line of code in the program is the SendMessage call, which is found in the windows.h file... SendMessage is a function used to basically make another window/program behave as you would want it to (ie: you can send messages to have a window minimize, maximize, close... whatever) .

SendMessage wants to know what window to send the message to. We used another function (defined in windows.h) called GetDesktopWindow, which will give us the "handle" or "hwnd" of the Desktop Window. An Hwnd is a unique hex value assigned to a window so that it can be identified by the OS. Every window has one. So, we get the hwnd for the desktop (with GetDesktopWindow) and use that hwnd, so that SendMessage knows which window we are sending a message to. The WM_SYSCOMMAND, let's the window know that we are about to send it a system command of some kind. The SC_SCREENSAVE (both WM_SYSCOMMAND and SC_SCREENSAVE are also defined in windows.h) tells the window that the particular system command, is to launch the screensaver. The zero is pretty much just a place-holder... in more complicated sendmessages it becomes needed for additional information, but 90% of the time it is zero. The return 0 (since we are returning from the main function) exits the program.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 111
Reputation: clutchkiller is an unknown quantity at this point 
Solved Threads: 1
clutchkiller's Avatar
clutchkiller clutchkiller is offline Offline
Junior Poster

Re: Quick question

 
0
  #7
Jan 2nd, 2009
Thank you very much for the in depth explanation, I am already familiar with the first half, but its always good to make sure your on top of your game, thanks a lot!
>That confuses me =(
Get used to it. Good programmers are in a constant state of confusion.
>Looks like i have some quasi specifics to investigate! Up Up And AWAY!
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Quick question

 
0
  #8
Jan 2nd, 2009
The Password issue is a whole lot uglier. Since I believe it was win2k or so, the password to get into the system from the screensaver is the account password. So, if you logged into XP as ClutchKiller, then the password for the screen saver is the same one that you used to log in to XP. So, what you are essentially looking for, is how do you change the account password.... and then put it back to what it was before..

Your Welcome
Last edited by Comatose; Jan 2nd, 2009 at 10:15 pm.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 111
Reputation: clutchkiller is an unknown quantity at this point 
Solved Threads: 1
clutchkiller's Avatar
clutchkiller clutchkiller is offline Offline
Junior Poster

Re: Quick question

 
0
  #9
Jan 2nd, 2009
hah, I was just scheming, and you tell me what you think about this idea, but what if i just ask for user input for a variable, and then once the screen saver is interrupted, i can do something like lock the desktop window until user inputs the correct variable code that was entered in console before SC_SCREENSAVE was called. So i guess instead of going through OS, just go through console. Sound doable? Maybe have the app detect mouse movement and thats when the console pops up again, and that would disable the screen saver as well, so that might reduce on the technicality of the source.
>That confuses me =(
Get used to it. Good programmers are in a constant state of confusion.
>Looks like i have some quasi specifics to investigate! Up Up And AWAY!
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 2,413
Reputation: Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough Comatose is a jewel in the rough 
Solved Threads: 211
Team Colleague
Comatose's Avatar
Comatose Comatose is offline Offline
Taboo Programmer

Re: Quick question

 
0
  #10
Jan 2nd, 2009
I'm not sure how you would go about locking the desktop window... I suppose you could try to use the "SetParent" API call, and essentially kidnap the desktop window... but I think putting it back may be a whole can of worms.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C++ Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC