'перехватчик сообщений Windows
- Код: Выделить всё
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 Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public Const GWL_WNDPROC = -4
Public lpPrevWndProc As Long
Public MyHWND As Long
Function WindowProc(ByVal hw As Long, ByVal uMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
'
WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam)
If uMsg <> WM_My Then GoTo 10
Me.WindowState = 0
10
End Function
'установить хук
Public Sub HookMsgWnd()
lpPrevWndProc = SetWindowLong(MyHWND, GWL_WNDPROC, AddressOf WindowProc)
End Sub
'снять хук
Public Sub UnHookMsgWnd()
Dim Temp As Long
Temp = SetWindowLong(MyHWND, GWL_WNDPROC, lpPrevWndProc)
End Sub