S
Stewart Berman
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.
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.