Welcome to irritatedVowel.com Sign in | Help

POKE 53280,0: Pete Brown's Blog

Silverlight, WPF, Windows Client Development, Woodworking, .NET Programming, CNC, Nature, and other topics.

Subscribe

Subscribe to my feed
Add to Technorati Favorites

My Book

Order my upcoming book, Silverlight in Action, covering Silverlight 4, ViewModel/MVVM, WCF RIA Services, MEF and more

About Pete Brown

Pete Brown is a Microsoft Developer Division Community Program Manager, focusing on Windows Client Development as well as a former Microsoft Silverlight MVP and INETA Speaker. Pete writes on a number of topics including Silverlight, WPF, .NET, woodworking and working as a consultant in the DC area. read more

Community Events


who's online

AddThis Social Bookmark Button

Temporarily Disable Screensaver in your WPF Code

I wrote a small media player for my son. I wrote the original version in Silverlight, but quickly ran into a problem where no matter what I did, Silverlight wouldn't read the larger video files (encoding was fine, so I'm pretty sure this is a 1.1 alpha bug). Anyway, I rewrote it as a WPF app. The first time it ran, my wife realized I had forgotten something very important: the screensaver.

So I searched around, and everything I saw was about writing to the registry to disable the screensaver. That just didn't smell right to me, so I dug deeper.

Eventually I ran across this great post that shows how to response to the appropriate windows messages to block the screensaver from starting up. I tested it in my WPF app and it worked like a charm (however, it didn't handle the power/monitor blanking properly. hmm).

For what it's worth, here's a screenshot of the very simple babysit...umm, media player I wrote for Ben :)

(That's Bear in the Big Blue House: The Rhythm Masters song)

The buttons on the right generate random playlists: one has two random episodes and two random songs, another has four random songs, one random episodes, etc. Below the playlist is a list of all the media files in the "Bear" folder on my media server. You can click on any of them to play the video. It's all really simple, with the only style/template used being a simple button template I snagged from a blog a while back.

The app runs under .NET 3.5 (beta 2) on my wife's laptop just outside the kitchen.

  Add to Technorati Favorites
Posted: Tuesday, September 25, 2007 11:07 PM by Pete.Brown
Filed under: , ,

Comments

Skup said:

Glad it could help ! I had seen such ugly things around the internet, like changing the monitor settings in the registry !! yerk ! I had no problem with the monitor power event ? What was your issue ? how did you solve it ?
# October 19, 2007 8:28 AM

Tim said:

here, i found this, it might help you, works good for me B): Private Sub DisableScreenIdle() Dim ResetTimer As New Timers.Timer(5900) AddHandler ResetTimer.Elapsed, AddressOf ResetIdle ResetTimer.Start() End Sub Private Sub ResetIdle() SetThreadExecutionState(&H2) End Sub Declare Function SetThreadExecutionState Lib "kernel32" (ByVal esFlags As Long) As Long
# March 25, 2009 12:31 PM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Enter the text you see in the image:

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS