Groups | Search | Server Info | Keyboard shortcuts | Login | Register


Groups > alt.support.programming > #7

OOPS fix on that hook fucntion

From "Nicholas Randall Forystek" <nforystek@neotext.org>
Newsgroups alt.bumbling.idiots.the.fbi, alt.comp.lang.visualbasic, alt.comp.programming, alt.support.programming, alt.talkers.programming, microsoft.private.mvp.visualbasic
Subject OOPS fix on that hook fucntion
Message-ID <adFPy.825697$fy.532560@fx45.am4> (permalink)
Organization xsusenet
Date 2016-04-13 23:42 -0500

Cross-posted to 6 groups.

Show all headers | View raw


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 

Back to alt.support.programming | Previous | Next | Find similar


Thread

OOPS fix on that hook fucntion "Nicholas Randall Forystek" <nforystek@neotext.org> - 2016-04-13 23:42 -0500

csiph-web