- Код: Выделить всё
Private Declare Function WaitMessage Lib "user32" () As Long
Private Declare Function PeekMessage Lib "user32" Alias "PeekMessageA" (lpMsg As Msg, ByVal hWnd As Long, ByVal wMsgFilterMin As Long, ByVal wMsgFilterMax As Long, ByVal wRemoveMsg As Long) As Long
Private Type POINTAPI
x As Long
y As Long
End Type
Private Type Msg
hWnd As Long
Message As Long
wParam As Long
lParam As Long
time As Long
pt As POINTAPI
End Type
Private Const PM_NOREMOVE As Long = &H0
Private Const WM_POWER As Long = &H48
Private Const WM_POWERBROADCAST As Long = &H218
Private Sub Form_Activate()
Pm
End Sub
Sub Pm()
Dim Message As Msg
Do
WaitMessage
If PeekMessage(Message, Me.hWnd, WM_POWERBROADCAST, WM_POWERBROADCAST, PM_NOREMOVE) Then
Debug.Print "123"
End If
DoEvents
Loop
End Sub
Пробовал подставлять WM_POWER-тоже никак.
В чём ошибка?,другие мессаги читаються.
Может надо подписываться на получение этих сообщений? Или это надо только в Висте?
Nic.