public bool hasClickEvent(){ if (ClickEvent != null) { return ClickEvent.GetInvocationList ().Length > 0; } else { return false; } }
public static IntPtr proc(int nCode, uint wParam, IntPtr lParam) { if (nCode >= 0) { if (wParam == WM_MOUSEMOVE && MoveEvent != null) { MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT)); Delegate[] receivers = MoveEvent.GetInvocationList(); foreach (MoveEventHandler receiver in receivers) { receiver.BeginInvoke(new MoveEventArgs(hookStruct.pt.x, hookStruct.pt.y), EndMoveEvent, null); } } else if ((wParam == WM_LBUTTONDOWN || wParam == WM_RBUTTONDOWN) && ClickEvent != null) { MSLLHOOKSTRUCT hookStruct = (MSLLHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(MSLLHOOKSTRUCT)); //ClickEvent.BeginInvoke(new ClickEventArgs(hookStruct, wParam == WM_LBUTTONDOWN), EndClickEvent, null); ClickEventArgs evt = new ClickEventArgs(hookStruct, wParam == WM_LBUTTONDOWN); Delegate[] receivers = ClickEvent.GetInvocationList(); foreach (ClickEventHandler receiver in receivers) { receiver.BeginInvoke(evt, EndClickEvent, null); } } } return(CallNextHookEx(hook, nCode, wParam, lParam)); }