PC Review


Reply
Thread Tools Rating: Thread Rating: 1 votes, 1.00 average.

Blanking Monitor and Unblanking Monitor

 
 
Stewart Berman
Guest
Posts: n/a
 
      15th Jun 2009
Is there a way to control blanking and unblanking a monitor -- basically override the power settings
and force the graphics card to blank out or to turn on?

I tried using the following:

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Int32,
ByVal wMsg As Int32, ByVal wParam As Int32, ByVal lParam As Int32) As Integer

Private Const SC_MONITORPOWER As Integer = &HF170&
Private Const HWND_BROADCAST As Integer = &HFFFF
Private Const WM_SYSCOMMAND As Integer = &H112

Public Enum MonitorStatus As Int32
Monitor_On = -1
Monitor_Low = 1
Monitor_Off = 2
End Enum


Public Sub SetMonitor(ByVal Monitor_Status As MonitorStatus)
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, Monitor_Status)
End Sub

Using:
SetMonitor(Wallpaper.MonitorStatus.Monitor_Off)
Sometimes only results in the graphics card blanking the screen for a few seconds.

Running a test loop:
Dim nCounter as Integer
For nCounter = 1 to 20
SetMonitor(Wallpaper.MonitorStatus.Monitor_Off)
Thread.Sleep(10000)
SetMonitor(Wallpaper.MonitorStatus.Monitor_On)
Thread.Sleep(10000)
Next nCounter
Seems to work -- at least after the first loop.

But
SetMonitor(Wallpaper.MonitorStatus.Monitor_On)
Does not unblank the screen if the power saver has blanked it.

The test machine is running Windows XP SP3 but the code needs to work for Vista as well.
 
Reply With Quote
 
 
 
 
Colbert Zhou [MSFT]
Guest
Posts: n/a
 
      16th Jun 2009
Hello Stewart,

I have tested the codes and they work fine for me in my side. I use the
following codes to test,

Dim nCounter As Integer
For nCounter = 1 To 20
SetMonitor(MonitorStatus.Monitor_On)
Thread.Sleep(70000)
Next nCounter

Please note we should let the thread sleep more than 60 seconds because the
Power Saver Option's minium time of turning off the display is 1 minute. If
the thread only sleeps for 10 seconds for each of the loop. The SetMonitor
function will send message broadcastly and the left time of display turning
off is refreshed. So we will never see the Power Saver turning off the
monitor.

Actually, I do the following things to test.
1. I set my Power Saver to turn off the monitor after 1 minutes if no
inputs are detected
2. I run the above codes.

After 1 minute, I see the Power Saver turnning off my Monitor, and then
after another 10(70-60) seconds, I can observe that my Monitor is turned on
by my application.

So when you say "SetMonitor(Wallpaper.MonitorStatus.Monitor_On) Does not
unblank the screen if the power saver has blanked it", would you mind
letting us know more specific steps and information, like how many minutes
you set in the system's Power Saver option and what is the exact codes you
are executing, as well as your test steps.

By the way, if I running your codes, it turns off the monitor for ten
seconds and then trun on the monitor for ten seconds as a cycle. Just works
like the codes indicate to be.


Best regards,
Ji Zhou
Microsoft Online Community Support

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
(E-Mail Removed).


 
Reply With Quote
 
Stewart Berman
Guest
Posts: n/a
 
      17th Jun 2009
I have a little application I use to explore managed code. It has a background task that changes
the wallpaper and then runs a little loop with a Thread.Sleep(6000) in it ten times. I added the
monitor on call right after the wallpaper is changed.

The intention is to not have the monitor blank out if the application is running.

My power settings are:
Power scheme: Home/Office Desk
Turn off monitor: After 20 mins
Turn off hard disks: Never
System standby: Never

I left the application running and went out of the office for around a half hour. When I got back
the monitor was blank. I assume it was because the power saving feature blanked the monitor. I hit
the down arrow and the monitor unblanked.

(E-Mail Removed) (Colbert Zhou [MSFT]) wrote:

>Hello Stewart,
>
>I have tested the codes and they work fine for me in my side. I use the
>following codes to test,
>
> Dim nCounter As Integer
> For nCounter = 1 To 20
> SetMonitor(MonitorStatus.Monitor_On)
> Thread.Sleep(70000)
> Next nCounter
>
>Please note we should let the thread sleep more than 60 seconds because the
>Power Saver Option's minium time of turning off the display is 1 minute. If
>the thread only sleeps for 10 seconds for each of the loop. The SetMonitor
>function will send message broadcastly and the left time of display turning
>off is refreshed. So we will never see the Power Saver turning off the
>monitor.
>
>Actually, I do the following things to test.
>1. I set my Power Saver to turn off the monitor after 1 minutes if no
>inputs are detected
>2. I run the above codes.
>
>After 1 minute, I see the Power Saver turnning off my Monitor, and then
>after another 10(70-60) seconds, I can observe that my Monitor is turned on
>by my application.
>
>So when you say "SetMonitor(Wallpaper.MonitorStatus.Monitor_On) Does not
>unblank the screen if the power saver has blanked it", would you mind
>letting us know more specific steps and information, like how many minutes
>you set in the system's Power Saver option and what is the exact codes you
>are executing, as well as your test steps.
>
>By the way, if I running your codes, it turns off the monitor for ten
>seconds and then trun on the monitor for ten seconds as a cycle. Just works
>like the codes indicate to be.
>
>
>Best regards,
>Ji Zhou
>Microsoft Online Community Support
>
>Delighting our customers is our #1 priority. We welcome your comments and
>suggestions about how we can improve the support we provide to you. Please
>feel free to let my manager know what you think of the level of service
>provided. You can send feedback directly to my manager at:
>(E-Mail Removed).
>


 
Reply With Quote
 
Stewart Berman
Guest
Posts: n/a
 
      17th Jun 2009
Then I set the Turn off monitor setting to one minute.

The monitor went off. Then it briefly flashed but before it could synchronize it went off.

I changed the code to:
turn on monitor
sleep one second
turn on monitor

The monitor went blank. This time it flashed and then I saw the desktop for a second and it went
blank.

So the turn on monitor does unblank it but something blanks it immediately after it turns on.

I am running Windows XP Pro SP3 with all patches. The motherboard is an ASUS A8N32-SLI Deluxe and I
am using the on board graphics.

Stewart Berman <(E-Mail Removed)> wrote:

>I have a little application I use to explore managed code. It has a background task that changes
>the wallpaper and then runs a little loop with a Thread.Sleep(6000) in it ten times. I added the
>monitor on call right after the wallpaper is changed.
>
>The intention is to not have the monitor blank out if the application is running.
>
>My power settings are:
>Power scheme: Home/Office Desk
>Turn off monitor: After 20 mins
>Turn off hard disks: Never
>System standby: Never
>
>I left the application running and went out of the office for around a half hour. When I got back
>the monitor was blank. I assume it was because the power saving feature blanked the monitor. I hit
>the down arrow and the monitor unblanked.
>
>(E-Mail Removed) (Colbert Zhou [MSFT]) wrote:
>
>>Hello Stewart,
>>
>>I have tested the codes and they work fine for me in my side. I use the
>>following codes to test,
>>
>> Dim nCounter As Integer
>> For nCounter = 1 To 20
>> SetMonitor(MonitorStatus.Monitor_On)
>> Thread.Sleep(70000)
>> Next nCounter
>>
>>Please note we should let the thread sleep more than 60 seconds because the
>>Power Saver Option's minium time of turning off the display is 1 minute. If
>>the thread only sleeps for 10 seconds for each of the loop. The SetMonitor
>>function will send message broadcastly and the left time of display turning
>>off is refreshed. So we will never see the Power Saver turning off the
>>monitor.
>>
>>Actually, I do the following things to test.
>>1. I set my Power Saver to turn off the monitor after 1 minutes if no
>>inputs are detected
>>2. I run the above codes.
>>
>>After 1 minute, I see the Power Saver turnning off my Monitor, and then
>>after another 10(70-60) seconds, I can observe that my Monitor is turned on
>>by my application.
>>
>>So when you say "SetMonitor(Wallpaper.MonitorStatus.Monitor_On) Does not
>>unblank the screen if the power saver has blanked it", would you mind
>>letting us know more specific steps and information, like how many minutes
>>you set in the system's Power Saver option and what is the exact codes you
>>are executing, as well as your test steps.
>>
>>By the way, if I running your codes, it turns off the monitor for ten
>>seconds and then trun on the monitor for ten seconds as a cycle. Just works
>>like the codes indicate to be.
>>
>>
>>Best regards,
>>Ji Zhou
>>Microsoft Online Community Support
>>
>>Delighting our customers is our #1 priority. We welcome your comments and
>>suggestions about how we can improve the support we provide to you. Please
>>feel free to let my manager know what you think of the level of service
>>provided. You can send feedback directly to my manager at:
>>(E-Mail Removed).
>>


 
Reply With Quote
 
Andrew Morton
Guest
Posts: n/a
 
      17th Jun 2009
Stewart Berman wrote:
> Is there a way to control blanking and unblanking a monitor --
> basically override the power settings and force the graphics card to
> blank out or to turn on?


http://blogs.msdn.com/oldnewthing/ar...13/629451.aspx

(Note that you shouldn't refer to setting the power state of the monitor as
"[un]blanking" it, because that means something different.)

Andrew


 
Reply With Quote
 
Stewart Berman
Guest
Posts: n/a
 
      17th Jun 2009
What the power saving process does is turn off the graphics output -- it does not power down the
monitor. When you watch the monitor and power saving kicks in it shows a signal loss message for a
few seconds and then blanks out. The monitor is still powered up.

The article you referenced says "attempting to trigger the system's monitor blank timeout", I take
that to mean blank the monitor. The reverse, which is what I am trying to do is unblank it.

So what is the difference between changing the Windows "power state" of the monitor and
blanking/unblanking it?

BTW, all of the links in the article to the dotnetjunkies.com site are broken..

"Andrew Morton" <(E-Mail Removed)> wrote:

>Stewart Berman wrote:
>> Is there a way to control blanking and unblanking a monitor --
>> basically override the power settings and force the graphics card to
>> blank out or to turn on?

>
>http://blogs.msdn.com/oldnewthing/ar...13/629451.aspx
>
>(Note that you shouldn't refer to setting the power state of the monitor as
>"[un]blanking" it, because that means something different.)
>
>Andrew
>


 
Reply With Quote
 
Stewart Berman
Guest
Posts: n/a
 
      27th Jun 2009
Did you see: (E-Mail Removed)


(E-Mail Removed) (Colbert Zhou [MSFT]) wrote:

>Hello Stewart,
>
>I have tested the codes and they work fine for me in my side. I use the
>following codes to test,
>
> Dim nCounter As Integer
> For nCounter = 1 To 20
> SetMonitor(MonitorStatus.Monitor_On)
> Thread.Sleep(70000)
> Next nCounter
>
>Please note we should let the thread sleep more than 60 seconds because the
>Power Saver Option's minium time of turning off the display is 1 minute. If
>the thread only sleeps for 10 seconds for each of the loop. The SetMonitor
>function will send message broadcastly and the left time of display turning
>off is refreshed. So we will never see the Power Saver turning off the
>monitor.
>
>Actually, I do the following things to test.
>1. I set my Power Saver to turn off the monitor after 1 minutes if no
>inputs are detected
>2. I run the above codes.
>
>After 1 minute, I see the Power Saver turnning off my Monitor, and then
>after another 10(70-60) seconds, I can observe that my Monitor is turned on
>by my application.
>
>So when you say "SetMonitor(Wallpaper.MonitorStatus.Monitor_On) Does not
>unblank the screen if the power saver has blanked it", would you mind
>letting us know more specific steps and information, like how many minutes
>you set in the system's Power Saver option and what is the exact codes you
>are executing, as well as your test steps.
>
>By the way, if I running your codes, it turns off the monitor for ten
>seconds and then trun on the monitor for ten seconds as a cycle. Just works
>like the codes indicate to be.
>
>
>Best regards,
>Ji Zhou
>Microsoft Online Community Support
>
>Delighting our customers is our #1 priority. We welcome your comments and
>suggestions about how we can improve the support we provide to you. Please
>feel free to let my manager know what you think of the level of service
>provided. You can send feedback directly to my manager at:
>(E-Mail Removed).
>


 
Reply With Quote
 
Colbert Zhou [MSFT]
Guest
Posts: n/a
 
      30th Jun 2009
Hi Stewart,

Sorry for the late response. But currently, based on my test, the
SendMessage with SC_MONITORPOWER being -1 works on Vista and Windows Server
2008. But, it indeed does not work for XP. I can reproduce it and also find
some previous discussion on the newsgroup about the same issue,

http://relatedterms.com/ViewThread.aspx?t=680395

http://www.microsoft.com/communities...aspx?dg=micros
oft.public.win32.programmer.kernel&tid=0e45deea-244b-4200-8c97-771e52e9257b&
cat=&lang=&cr=&sloc=&m=1&p=1

Because XP is out if its main product life cycle. So there will not be a SP
or hotfix to change this behavior. So, if our objective is keeping the
Monitor on when our applicatio running, we may have to find some
alternative ways to work around it. What about the approaches of the
"Keeping the Monitor Turned ON" comment in this article?
http://www.codeproject.com/KB/cs/Mon...ent_guide.aspx

For your convenience, I quote it here,
"Hi, My requirements are to keep the Monitor ON for the Lifetime of my App.
So how can it be done?

Thanks...

Re: Keeping the Monitor Turned ON Dalibor Drzik 12:22 6 Sep '07

LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
lParam)
{
switch (message)
{
case WM_SYSCOMMAND:

switch (wParam)
{
// disable screen saver and monitor power-saving mode
case SC_SCREENSAVE:
case SC_MONITORPOWER:

return 0;
}

break;

case WM_DESTROY:

PostQuitMessage(0);

return 0;
}

return DefWindowProc(hwnd, message, wParam, lParam);
}
"

The idea is just to hook the SC_MONITORPOWER and SC_SCREENSAVE message in
the application's message loop. Someone in the C# forum has a .NET version
codes to do this,
http://social.msdn.microsoft.com/For...read/da9554dc-
1da8-4648-97a2-351d5656e15c


Best regards,
Colbert Zhou
Microsoft Newsgroup Support Team



-----------------------------------------------------------------------------
Less Spam Better enjoyable experience
Visit : news://spacesst.com
 
Reply With Quote
 
Stewart Berman
Guest
Posts: n/a
 
      30th Jun 2009
>http://www.microsoft.com/communities...aspx?dg=micros
>oft.public.win32.programmer.kernel&tid=0e45deea-244b-4200-8c97-771e52e9257b&
>cat=&lang=&cr=&sloc=&m=1&p=1


This thread has the following comment:

"As the only way out, I found an option of changing power policy settings
(because besides screen saver, the monitor itself can be shut off too, which
I should think of as well), but the problem is that if another program or a
user changes those power settings too while my app is running how would I
know that and not change it back to what it was at exit. Unfortunately, I
can't find any indication of notifications sent for power policy changes in
Windows XP. "

But does not include any code or even a hint of how to change power policy settings. (I already
have an application that blocks a screen saver from firing by wiggling the tail of the mouse.)

>http://www.codeproject.com/KB/cs/Mon...ent_guide.aspx


This thread uses the same method I tried -- it just provides ways different ways of sending the same
information to the defproc routine at the end of most window's message processing.

However, I think I found the answer here:
http://msdn.microsoft.com/en-us/library/aa373208(VS.85).aspx

Will try it later today and let you know if I can get it to work in my app.

(E-Mail Removed) (Colbert Zhou [MSFT]) wrote:

>Hi Stewart,
>
>Sorry for the late response. But currently, based on my test, the
>SendMessage with SC_MONITORPOWER being -1 works on Vista and Windows Server
>2008. But, it indeed does not work for XP. I can reproduce it and also find
>some previous discussion on the newsgroup about the same issue,
>
>http://relatedterms.com/ViewThread.aspx?t=680395
>
>http://www.microsoft.com/communities...aspx?dg=micros
>oft.public.win32.programmer.kernel&tid=0e45deea-244b-4200-8c97-771e52e9257b&
>cat=&lang=&cr=&sloc=&m=1&p=1
>
>Because XP is out if its main product life cycle. So there will not be a SP
>or hotfix to change this behavior. So, if our objective is keeping the
>Monitor on when our applicatio running, we may have to find some
>alternative ways to work around it. What about the approaches of the
>"Keeping the Monitor Turned ON" comment in this article?
>http://www.codeproject.com/KB/cs/Mon...ent_guide.aspx
>
>For your convenience, I quote it here,
>"Hi, My requirements are to keep the Monitor ON for the Lifetime of my App.
>So how can it be done?
>
>Thanks...
>
>Re: Keeping the Monitor Turned ON Dalibor Drzik 12:22 6 Sep '07
>
>LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
>lParam)
>{
>switch (message)
>{
>case WM_SYSCOMMAND:
>
>switch (wParam)
>{
>// disable screen saver and monitor power-saving mode
>case SC_SCREENSAVE:
>case SC_MONITORPOWER:
>
>return 0;
>}
>
>break;
>
>case WM_DESTROY:
>
>PostQuitMessage(0);
>
>return 0;
>}
>
>return DefWindowProc(hwnd, message, wParam, lParam);
>}
>"
>
>The idea is just to hook the SC_MONITORPOWER and SC_SCREENSAVE message in
>the application's message loop. Someone in the C# forum has a .NET version
>codes to do this,
>http://social.msdn.microsoft.com/For...read/da9554dc-
>1da8-4648-97a2-351d5656e15c
>
>
>Best regards,
>Colbert Zhou
>Microsoft Newsgroup Support Team
>


 
Reply With Quote
 
Stewart Berman
Guest
Posts: n/a
 
      1st Jul 2009
I can now reset the power saver timer. It also resets the screen saver timer.

(E-Mail Removed) (Colbert Zhou [MSFT]) wrote:

>Hi Stewart,
>
>Sorry for the late response. But currently, based on my test, the
>SendMessage with SC_MONITORPOWER being -1 works on Vista and Windows Server
>2008. But, it indeed does not work for XP. I can reproduce it and also find
>some previous discussion on the newsgroup about the same issue,
>
>http://relatedterms.com/ViewThread.aspx?t=680395
>
>http://www.microsoft.com/communities...aspx?dg=micros
>oft.public.win32.programmer.kernel&tid=0e45deea-244b-4200-8c97-771e52e9257b&
>cat=&lang=&cr=&sloc=&m=1&p=1
>
>Because XP is out if its main product life cycle. So there will not be a SP
>or hotfix to change this behavior. So, if our objective is keeping the
>Monitor on when our applicatio running, we may have to find some
>alternative ways to work around it. What about the approaches of the
>"Keeping the Monitor Turned ON" comment in this article?
>http://www.codeproject.com/KB/cs/Mon...ent_guide.aspx
>
>For your convenience, I quote it here,
>"Hi, My requirements are to keep the Monitor ON for the Lifetime of my App.
>So how can it be done?
>
>Thanks...
>
>Re: Keeping the Monitor Turned ON Dalibor Drzik 12:22 6 Sep '07
>
>LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM
>lParam)
>{
>switch (message)
>{
>case WM_SYSCOMMAND:
>
>switch (wParam)
>{
>// disable screen saver and monitor power-saving mode
>case SC_SCREENSAVE:
>case SC_MONITORPOWER:
>
>return 0;
>}
>
>break;
>
>case WM_DESTROY:
>
>PostQuitMessage(0);
>
>return 0;
>}
>
>return DefWindowProc(hwnd, message, wParam, lParam);
>}
>"
>
>The idea is just to hook the SC_MONITORPOWER and SC_SCREENSAVE message in
>the application's message loop. Someone in the C# forum has a .NET version
>codes to do this,
>http://social.msdn.microsoft.com/For...read/da9554dc-
>1da8-4648-97a2-351d5656e15c
>
>
>Best regards,
>Colbert Zhou
>Microsoft Newsgroup Support Team
>


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Safely removing devices and monitor blanking issue LostinUSBland Windows Vista General Discussion 4 19th Feb 2008 07:53 PM
how do I stop video from displaying full screen on second monitor in dual monitor setup TJ Windows XP Video 1 18th Nov 2005 10:39 PM
Monitor won't start; virus has possibly corrupted monitor driver or other files Christine Huber Windows XP General 4 28th Apr 2004 01:06 AM
Installing Catalyst 4.4 to Dual-Monitor System Results In First Monitor Disappearing CHANGE USERNAME TO westes ATI Video Cards 2 26th Apr 2004 05:55 PM
no TV recovery after monitor blanking PM JAD ATI Video Cards 1 31st Jul 2003 06:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:54 AM.