how do I watch for the powerrequest message
How do I watch for it to come and what is the exact syntax on sending back a fail message. Thank you for the help
Joe
Thank you Megatron for the additional help...
Do I also need to include the constant for pwr_fail as well as GWL_WNDPROC? If not then I am still eithering doing some wrong, or the code is not ME compliant. It is needed for 95, but will it work in 98/NT/ME? Maybe that is my problem at this point. Thank you both for all your help.
Literally the code I am using that pertains to suspension:
Module1.mod:
Public OldProcAddress As Long
Private Const WM_POWER = &H48
Private Const PWR_SUSPENDREQUEST = 1
Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Function VB_WindowProc(ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
On Local Error Resume Next
Dim lRet As Long
'\\ If its a power suspending broadcast, kill it...
If wMsg = WM_POWER And wParam = PWR_SUSPENDREQUEST Then
VB_WindowProc = PWR_FAIL
Else
VB_WindowProc = CallWindowProc(OldProcAddress, hWnd, wMsg, wParam, lParam)
End If
End Function
Form1:
Private Sub Form_Unload(Cancel As Integer)
Call SetWindowLong(Me.hWnd, GWL_WNDPROC, OldProcAddress)
End Sub
Private Sub Form_Load()
OldProcAddress = SetWindowLong(Me.hWnd, GWL_WNDPROC, AddressOf VB_WindowProc)
end Sub
Sincerely,
Joe