Option ExplicitPublic Const GWL_WNDPROC = (-4) 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 Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongPublic WinProc As Long Public Const WM_GETTEXT = &HD Public Sub rNoGetText(ByVal TextWnd As Long) WinProc = GetWindowLong(TextWnd, GWL_WNDPROC) SetWindowLong TextWnd, GWL_WNDPROC, AddressOf WndProc End SubPublic Sub nNoGetText(ByVal TextWnd As Long) SetWindowLong TextWnd, GWL_WNDPROC, WinProc WinProc = 0 End SubFunction WndProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long If Msg = WM_GETTEXT Then Else WndProc = CallWindowProc(WinProc, hWnd, Msg, wParam, lParam) End If End Function
不一定要说是钩子函数,其实主要是sendwindowlong和callwindowproc这两个函数.
回调等都属于一个范畴.就好比类和对象
不一定要说是钩子函数,其实主要是sendwindowlong和callwindowproc这两个函数.
回调等都属于一个范畴.就好比类和对象
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
Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long) As Long
Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hWnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As LongPublic WinProc As Long
Public Const WM_GETTEXT = &HD
Public Sub rNoGetText(ByVal TextWnd As Long)
WinProc = GetWindowLong(TextWnd, GWL_WNDPROC)
SetWindowLong TextWnd, GWL_WNDPROC, AddressOf WndProc
End SubPublic Sub nNoGetText(ByVal TextWnd As Long)
SetWindowLong TextWnd, GWL_WNDPROC, WinProc
WinProc = 0
End SubFunction WndProc(ByVal hWnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If Msg = WM_GETTEXT Then
Else
WndProc = CallWindowProc(WinProc, hWnd, Msg, wParam, lParam)
End If
End Function