Disabling The Screensaver

Started by
3 comments, last by Ancient Spirit 18 years, 8 months ago
Hello... Can you please tell me how do i disable the screensaver? And how do i disable the Power Settings? In other words, how do i prevent the monitor from turning off and the garddisk from turning off? I am writing under C++ Win32 SDK and OpenGL. Thanks in advance!
This world is ruled by big furry CATS!! :)Meow! :)
Advertisement
In your WndProc, simply intercept the message, like so:


    LRESULT CALLBACK WndProc (HWND hwnd, UINT iMsg, WPARAM wParam, LPARAM lParam){	if(ShowConsole == true)	{			RecvConsoleInput(hwnd, iMsg, wParam, lParam);	}    switch (iMsg)	    {      //All your other messages go here		case WM_SYSCOMMAND://if its a system command		{			switch (wParam)//enter the switch			{				case SC_SCREENSAVE://intercept the screensaver                                return 0;//prevent it from happening				case SC_MONITORPOWER://intercept the powersave				return 0;//prevent it from happening			}			break;		}				}													  return DefWindowProc (hwnd, iMsg, wParam, lParam);		 										 }			


This just fits in with your other messages. How this works is when the system sends the message, your application intercepts it, does nothing, and then tell windows it’s handled the situation. And thus, the screensaver doesn’t appear!

Thank you! But what about the "Turn Off Hardisk" ?? I need to cancel it aswell... Does anyone knows how?

Thanks in advance.
This world is ruled by big furry CATS!! :)Meow! :)
The hard drives will only spin down if there's no disk activity. If there is disk activity and the system is not suspended/powersaving (which you've taken care of by intercepting the appropriate messages), they'll spin up again.
- k2"Choose a job you love, and you'll never have to work a day in your life." — Confucius"Logic will get you from A to B. Imagination will get you everywhere." — Albert Einstein"Money is the most egalitarian force in society. It confers power on whoever holds it." — Roger Starr{General Programming Forum FAQ} | {Blog/Journal} | {[email=kkaitan at gmail dot com]e-mail me[/email]} | {excellent webhosting}
Riiighttt.... *FEELS STUPID...*
Thanks :)
This world is ruled by big furry CATS!! :)Meow! :)

This topic is closed to new replies.

Advertisement