Nicholas Randall Forystek
unread,Apr 14, 2016, 12:42:48 AM4/14/16You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
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