// ************************************************************************ // ************************************************************************ // Default filter function protected int CoreHookProc(int code, IntPtr wParam, IntPtr lParam) { if (code < 0) { return(CallNextHookEx(MHhook, code, wParam, lParam)); } // Let clients determine what to do var e = new HookEventArgs { HookCode = code, WParam = wParam, LParam = lParam }; OnHookInvoked(e); // Yield to the next hook in the chain return(CallNextHookEx(MHhook, code, wParam, lParam)); }
/// <summary> /// Handle messages for context menu /// </summary> private void WindowsHookInvoked(object sender, HookEventArgs e) { var cwp = (Cwpstruct)Marshal.PtrToStructure(e.LParam, typeof(Cwpstruct)); if (_oContextMenu2 != null && (cwp.message == (int)Wm.InitMenuPopup || cwp.message == (int)Wm.MeasureItem || cwp.message == (int)Wm.DrawItem)) { if (_oContextMenu2.HandleMenuMsg((uint)cwp.message, cwp.wparam, cwp.lparam) == S_OK) { return; } } if (_oContextMenu3 == null || cwp.message != (int)Wm.MenuChar) { return; } if (_oContextMenu3.HandleMenuMsg2((uint)cwp.message, cwp.wparam, cwp.lparam, IntPtr.Zero) == S_OK) { } }
protected void OnHookInvoked(HookEventArgs e) { HookInvoked?.Invoke(this, e); }