m_hHook As Long
Private m_lHookWndProc As Long

Public Sub HookAttach()
   m_hHook = SetWindowsHookEx(WH_CALLWNDPROC, AddressOf AppHook, App.hInstance,
    App.ThreadID)
   Debug.Assert m_hHook &lt;&gt; 0
End Sub
Public Sub HookDetach()
   If m_hHook &lt;&gt; 0 Then
      UnhookWindowsHookEx m_hHook
      m_hHook = 0
   End If
End Sub

Private Function AppHook(ByVal idHook As Long, ByVal wParam As Long, ByVal
 lParam As Long) As Long
Dim CWP As CWPSTRUCT
Dim k As Long, aClass As String
    
   If idHook &gt