473,769 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Preventing Screen Saver from Windows Forms application

KK
Dear All
I want to prevent the screen saver getting activated when my application is
running.
I have the following code, but still screen saver is activated. What
corrections I should make to prevent screen saver running to the following
code.

public class MainForm : System.Windows. Forms.Form
{
private static readonly int SC_SCREENSAVE = 0xF140;
private static readonly int WM_SYSCOMMAND = 0x0112;
private static readonly int WM_CLOSE = 0x0010;
protected override void WndProc(ref Message m)
{
if (WM_SYSCOMMAND == m.Msg && SC_SCREENSAVE == (int)m.WParam)
{
m.Result = (IntPtr)(-1);
System.Diagnost ics.Trace.Write Line("Screen Saver event handled");
return;
}
base.WndProc(re f m)
}
}

Krishna Rao K Lucid Software Ltd 104, NSIC STP Complex | Guindy Industrial
Estate | Ekkattuthangal | Chennai 600032 ' +91 44 2225 2273 / 76 , +91 98407
28998
Oct 30 '07 #1
3 5762
Hello KK,

Make P/Invoke call to SystemParameter sInfo with SPI_SETSCREENSA VEACTIVE,
setting uiParam = false to disable, true to activate

http://pinvoke.net/default.aspx/user...etersInfo.html

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo
KDear All
KI want to prevent the screen saver getting activated when my
Kapplication is
Krunning.
KI have the following code, but still screen saver is activated. What
Kcorrections I should make to prevent screen saver running to the
Kfollowing code.
K>
Kpublic class MainForm : System.Windows. Forms.Form
K{
Kprivate static readonly int SC_SCREENSAVE = 0xF140;
Kprivate static readonly int WM_SYSCOMMAND = 0x0112;
Kprivate static readonly int WM_CLOSE = 0x0010;
Kprotected override void WndProc(ref Message m)
K{
Kif (WM_SYSCOMMAND == m.Msg && SC_SCREENSAVE == (int)m.WParam)
K{
Km.Result = (IntPtr)(-1);
KSystem.Diagnos tics.Trace.Writ eLine("Screen Saver event
Khandled");
Kreturn;
K}
Kbase.WndProc(r ef m)
K}
K}
KKrishna Rao K Lucid Software Ltd 104, NSIC STP Complex | Guindy
KIndustrial Estate | Ekkattuthangal | Chennai 600032 ' +91 44 2225
K2273 / 76 , +91 98407 28998
K>
Oct 30 '07 #2
KK
Hi Nemtsev
Thank you very much. i have small doubt.
When we call SystemParameter sInfo as suggested, what's the scope of this
method call.
I mean will it disable the screen saver completly or only during the life
time of my application?
Thanks once again.

<Michael Nemtsev>; "MVP" <ne*****@msn.co mwrote in message
news:3d******** *************** ***@msnews.micr osoft.com...
Hello KK,

Make P/Invoke call to SystemParameter sInfo with SPI_SETSCREENSA VEACTIVE,
setting uiParam = false to disable, true to activate

http://pinvoke.net/default.aspx/user...etersInfo.html

---
WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

KDear All
KI want to prevent the screen saver getting activated when my
Kapplication is
Krunning.
KI have the following code, but still screen saver is activated. What
Kcorrections I should make to prevent screen saver running to the
Kfollowing code.
KKpublic class MainForm : System.Windows. Forms.Form
K{
Kprivate static readonly int SC_SCREENSAVE = 0xF140;
Kprivate static readonly int WM_SYSCOMMAND = 0x0112;
Kprivate static readonly int WM_CLOSE = 0x0010;
Kprotected override void WndProc(ref Message m)
K{
Kif (WM_SYSCOMMAND == m.Msg && SC_SCREENSAVE == (int)m.WParam)
K{
Km.Result = (IntPtr)(-1);
KSystem.Diagnos tics.Trace.Writ eLine("Screen Saver event
Khandled");
Kreturn;
K}
Kbase.WndProc(r ef m)
K}
K}
KKrishna Rao K Lucid Software Ltd 104, NSIC STP Complex | Guindy
KIndustrial Estate | Ekkattuthangal | Chennai 600032 ' +91 44 2225
K2273 / 76 , +91 98407 28998
K>

Oct 30 '07 #3
Well, it should be pretty easy to try it and find out, yes? Let us know.

-- Peter
Recursion: see Recursion
site: http://www.eggheadcafe.com
unBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder: http://www.blogmetafinder.com

"KK" wrote:
Hi Nemtsev
Thank you very much. i have small doubt.
When we call SystemParameter sInfo as suggested, what's the scope of this
method call.
I mean will it disable the screen saver completly or only during the life
time of my application?
Thanks once again.

<Michael Nemtsev>; "MVP" <ne*****@msn.co mwrote in message
news:3d******** *************** ***@msnews.micr osoft.com...
Hello KK,

Make P/Invoke call to SystemParameter sInfo with SPI_SETSCREENSA VEACTIVE,
setting uiParam = false to disable, true to activate

http://pinvoke.net/default.aspx/user...etersInfo.html

---
WBR, Michael Nemtsev [.NET/C# MVP] :: blog:
http://spaces.live.com/laflour
"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

KDear All
KI want to prevent the screen saver getting activated when my
Kapplication is
Krunning.
KI have the following code, but still screen saver is activated. What
Kcorrections I should make to prevent screen saver running to the
Kfollowing code.
KKpublic class MainForm : System.Windows. Forms.Form
K{
Kprivate static readonly int SC_SCREENSAVE = 0xF140;
Kprivate static readonly int WM_SYSCOMMAND = 0x0112;
Kprivate static readonly int WM_CLOSE = 0x0010;
Kprotected override void WndProc(ref Message m)
K{
Kif (WM_SYSCOMMAND == m.Msg && SC_SCREENSAVE == (int)m.WParam)
K{
Km.Result = (IntPtr)(-1);
KSystem.Diagnos tics.Trace.Writ eLine("Screen Saver event
Khandled");
Kreturn;
K}
Kbase.WndProc(r ef m)
K}
K}
KKrishna Rao K Lucid Software Ltd 104, NSIC STP Complex | Guindy
KIndustrial Estate | Ekkattuthangal | Chennai 600032 ' +91 44 2225
K2273 / 76 , +91 98407 28998
K>


Oct 30 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2516
by: Card.Starzinger | last post by:
Hi! I need help to simulate programmatically user interaction on WinNT 4.0, to avoid screen saver activation. I try with key injection event. SendInput API and keybd_event API work correctly with Win2000 and WinXP system. Screen saver don't start.
0
1929
by: jimvn | last post by:
while my screen saver (webshots) is active, my vb.net windows app updates a textbox. after exiting the password protected screen saver, the text box does not appear to be updated, but it has been, i.e. old data is still displayed on screen, but the program has correctly updated it. I issue a textbox.refresh, a form.refresh and an application.doevents after updating the textbox. this was reported as a windows bug way back in NT; my...
3
2365
by: Thom Little | last post by:
How do I invoke the current screen saver with C#? Where did you find the information on how to do it? -- -- Thom Little -- www.tlaNET.net -- Thom Little Associates, Ltd. --
12
11577
by: Rob | last post by:
Is there a way that VB can know when the operating system goes into screen save mode? I have continuous polling I wish to pause while in screen save mode. And likewise to wake back up when the screen saver is turned back off. Any help on this will be greatly appreciated. Rob
2
1088
by: Kurien Baker Fenn | last post by:
I have developed a screen saver with 10 different images.when the screen saver is executed in my computer it is in the center.but when i execute the screen saver in a computer with a different resolution ,the images are not centered.can you please suggest. Thank you
0
3282
by: Jeffery Tyree | last post by:
I have a machine that will be used to demo some Excel spreadsheets at a convention. Because I did not author the spreadsheets and attendees will be allowed to play with the spreadsheets, I needed a way to periodically restore the original versions. In addition to the "always-on-top click this button to reset demo" application I wrote, I chose to use screen saver code to reset the demo after a period of inactivity in the event an attendee...
1
2222
by: Mark van Dijk | last post by:
Hi there, I have a farely simple question that I can't seem to find the answer to. I've got a C# Winforms application that after building results in an executable. This executable is then renamed to an .scr file and used as a Screen Saver. How can I get this file to come up with a different name than the
1
2378
by: ashwiniappajigowda | last post by:
Hi, I have an simple MFC dialog based application. On launch of that application 'Password protected screen saver' is not getting activated after the screen saver timeout. If 'On resume, password protect' option unchecked, I am getting the Screen saver. Application not generating any of the keyboard or any user events to
0
1263
by: rehanrana | last post by:
I built application in VB6, my application appear in system tray, when I double click on icon of my application, it run screen saver, my screen saver shows images and news. Screen saver functionality is that when user press F2 key, my screen saver open news detail in browser. But the problem is that when screen saver stop (close), browser also close with the screen saver. following line i use to start screen saver lRet =...
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10212
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10047
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9863
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5447
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.