Private Const SC_MONITORPOWER = &HF170&
Private Const MONITOR_OFF = 2&
Private Const MONITOR_ON = -1&
Private Const MONITOR_STANDBY = 1&
以下是我的子类代码:
If (uMsg = WM_SYSCOMMAND) Then
If (wParam = SC_MONITORPOWER) Then
If (lParam = MONITOR_OFF) Then
'I do receive this event!
Debug.Print("Monitor is turned off")
ElseIf (lParam = MONITOR_ON) Then
Stop 'This is never called
Else
Stop 'This is never called
End If
End If
End If
如果显示器进入睡眠状态,将广播WM_SYSCOMMAND消息。
但是,当显示器再次开启(例如通过移动鼠标)时,我没有收到WM_SYSCOMMAND消息。
我该如何跟踪显示器何时重新激活/开启?
我做错了什么吗?
谢谢!
(61808 And &HFFF0) = 61808
,因此当wParam = 61808
时,“If ((wParam And &HFFF0) = SC_MONITORPOWER) Then”应该评估为True。无论如何,这是无关紧要的,因为您刚才说在打开监视器时甚至没有收到“WM_SYSCOMMAND”消息。您昨天没有说过这一点。 - Remy Lebeau