// ************************************************************************ // ************************************************************************ // 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 var 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)); }
/// <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) { if (_oContextMenu3.HandleMenuMsg2((uint)cwp.message, cwp.wparam, cwp.lparam, IntPtr.Zero) == S_OK) { } } }