C
Craig Graham
I'm trying to get some VB.NET code to turn off the backlight of the LCD
monitor on a machine we've built.
The code
**********
' For switching off the backlight
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam
As Long) As Long
Const SC_MONITORPOWER As Long = &HF170&
Const MONITOR_ON As Long = -1&
Const MONITOR_OFF As Long = 2&
Const WM_SYSCOMMAND As Long = &H112
SendMessage Me.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF
************
works on a desktop machine running XP Home and a CRT monitor, however on a
laptop running XP Pro, a desktop machine with LCD monitor and XP pro and a
test machine with LCD monitor running Windows 2000 it simply fails silently.
It is the same code copied across, so there is no possibility of a typing
error. On both misbehaving machines, I've verified that if I set the power
management from Display Properties to turn off the monitor, the display and
backlight do indeed switch off. The LCD monitor is integrated into the
Win2000 machine so I cannot see if this is some bizarre problem with LCD and
CRT displays.
Googling has not helped, so I'm hoping someone here can cast some light on
this.
monitor on a machine we've built.
The code
**********
' For switching off the backlight
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam
As Long) As Long
Const SC_MONITORPOWER As Long = &HF170&
Const MONITOR_ON As Long = -1&
Const MONITOR_OFF As Long = 2&
Const WM_SYSCOMMAND As Long = &H112
SendMessage Me.hWnd, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF
************
works on a desktop machine running XP Home and a CRT monitor, however on a
laptop running XP Pro, a desktop machine with LCD monitor and XP pro and a
test machine with LCD monitor running Windows 2000 it simply fails silently.
It is the same code copied across, so there is no possibility of a typing
error. On both misbehaving machines, I've verified that if I set the power
management from Display Properties to turn off the monitor, the display and
backlight do indeed switch off. The LCD monitor is integrated into the
Win2000 machine so I cannot see if this is some bizarre problem with LCD and
CRT displays.
Googling has not helped, so I'm hoping someone here can cast some light on
this.