/// <summary> /// Notifies subscribers of the mouse event /// </summary> /// <param name="wParam">wParam</param> /// <param name="mouseHookStruct">Contains event info</param> /// <param name="handled">set to true if handled</param> private void notifyEvent(MouseWParam wParam, MSLLHOOKSTRUCT mouseHookStruct, ref bool handled) { var button = MouseButtons.None; MouseEventHandler mouseEvent = null; int delta = 0; switch (wParam) { case MouseWParam.WM_NCLBUTTONDOWN: case MouseWParam.WM_LBUTTONDOWN: button = MouseButtons.Left; mouseEvent = EvtMouseDown; break; case MouseWParam.WM_RBUTTONDOWN: case MouseWParam.WM_NCRBUTTONDOWN: button = MouseButtons.Right; mouseEvent = EvtMouseDown; break; case MouseWParam.WM_MBUTTONDOWN: case MouseWParam.WM_NCMBUTTONDOWN: button = MouseButtons.Middle; mouseEvent = EvtMouseDown; break; case MouseWParam.WM_NCLBUTTONUP: case MouseWParam.WM_LBUTTONUP: button = MouseButtons.Left; mouseEvent = EvtMouseUp; break; case MouseWParam.WM_RBUTTONUP: case MouseWParam.WM_NCRBUTTONUP: button = MouseButtons.Right; mouseEvent = EvtMouseUp; break; case MouseWParam.WM_MBUTTONUP: case MouseWParam.WM_NCMBUTTONUP: button = MouseButtons.Middle; mouseEvent = EvtMouseUp; break; case MouseWParam.WM_MOUSEMOVE: case MouseWParam.WM_NCMOUSEMOVE: mouseEvent = EvtMouseMove; break; case MouseWParam.WM_NCLBUTTONDBLCLK: case MouseWParam.WM_LBUTTONDBLCLK: button = MouseButtons.Left; mouseEvent = EvtMouseDblClick; break; case MouseWParam.WM_NCRBUTTONDBLCLK: case MouseWParam.WM_RBUTTONDBLCLK: button = MouseButtons.Right; mouseEvent = EvtMouseDblClick; break; case MouseWParam.WM_NCMBUTTONDBLCLK: case MouseWParam.WM_MBUTTONDBLCLK: button = MouseButtons.Middle; mouseEvent = EvtMouseDblClick; break; case MouseWParam.WM_MOUSEWHEEL: case MouseWParam.WM_MOUSEHWHEEL: delta = mouseHookStruct.mouseData >> 16; mouseEvent = EvtMouseWheel; break; } if (mouseEvent != null) { var args = new MouseEventArgs(button, 1, mouseHookStruct.pt.x, mouseHookStruct.pt.y, delta); mouseEvent(this, args); } }