protected void OnHookInvoked(HookEventArgs e) { if (HookInvoked != null) { HookInvoked(this, e); } }
// ************************************************************** // ************************************************************** // Handles the hook event private void CbtHookInvoked(object sender, HookEventArgs e) { CbtHookAction code = (CbtHookAction)e.HookCode; IntPtr wParam = e.wParam; IntPtr lParam = e.lParam; // Handle hook events (only a few of available actions) switch (code) { case CbtHookAction.HCBT_CREATEWND: HandleCreateWndEvent(wParam, lParam); break; case CbtHookAction.HCBT_DESTROYWND: HandleDestroyWndEvent(wParam, lParam); break; case CbtHookAction.HCBT_ACTIVATE: HandleActivateEvent(wParam, lParam); break; } return; }
// ************************************************************************ // ************************************************************************ // Default filter function protected int CoreHookProc(int code, IntPtr wParam, IntPtr lParam) { if (code < 0) { return(CallNextHookEx(m_hhook, code, wParam, lParam)); } // Let clients determine what to do HookEventArgs e = new HookEventArgs(); e.HookCode = code; e.wParam = wParam; e.lParam = lParam; OnHookInvoked(e); // Yield to the next hook in the chain return(CallNextHookEx(m_hhook, code, wParam, lParam)); }
protected void OnHookInvoked(HookEventArgs e) { if (HookInvoked != null) HookInvoked(this, e); }
// ************************************************************************ // ************************************************************************ // Default filter function protected int CoreHookProc(int code, IntPtr wParam, IntPtr lParam) { if (code < 0) return CallNextHookEx(m_hhook, code, wParam, lParam); // Let clients determine what to do HookEventArgs e = new HookEventArgs(); e.HookCode = code; e.wParam = wParam; e.lParam = lParam; OnHookInvoked(e); // Yield to the next hook in the chain return CallNextHookEx(m_hhook, code, wParam, lParam); }