Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

OOPS fix on that hook fucntion

1 view
Skip to first unread message

Nicholas Randall Forystek

unread,
Apr 14, 2016, 12:42:48 AM4/14/16
to
Public Static Function HookControl(ByRef obj) As Object
Static HookedCtrls As Collection
Static HookedAddrs As Collection
If HookedCtrls Is Nothing Then
Set HookedCtrls = New Collection
Set HookedAddrs = New Collection
End If
If IsNumeric(obj) Then
Set HookControl = HookedCtrls("k" & obj.hWnd)
ElseIf HookedCtrls.Count > 0 Then
Dim cnt As Long
For cnt = 1 To HookedAddrs.Count
If HookedCtrls(cnt).hWnd = obj.hWnd Then
GoTo unhook
End If
Next
End If
HookedCtrls.Add obj, "k" & obj.hWnd
HookedAddrs.Add GetWindowLong(obj.hWnd, GWL_WNDPROC), "k" & obj.hWnd
SetWindowLong obj.hWnd, GWL_WNDPROC, AddressOf ControlWndProc
GoTo hookok
unhook:
SetWindowLong obj.hWnd, GWL_WNDPROC, HookedAddrs("k" & obj.hWnd)
HookedCtrls.Remove "k" & obj.hWnd
HookedAddrs.Remove "k" & obj.hWnd
hookok:
If HookedCtrls.Count = 0 Then
Set HookedCtrls = Nothing
Set HookedAddrs = Nothing
End If
End Function


0 new messages