protected void OnMouseMove(EventArgsMouse ehargs)
 {
     if (EhMouseMove == null)
     {
         return;
     }
     this.EhMouseMove(this, ehargs);
 }
 protected void OnMouseDown(EventArgsMouse ehargs)
 {
     if (EhMouseDown == null)
     {
         return;
     }
     this.EhMouseDown(this, ehargs);
 }
 protected void OnMouseClick(EventArgsMouse ehargs)
 {
     if (EhMouseClick == null)
     {
         return;
     }
     this.EhMouseClick(this, ehargs);
 }
 protected void OnMouseWheel(EventArgsMouse ehargs)
 {
     if (EhMouseWheel == null)
     {
         return;
     }
     this.EhMouseWheel(this, ehargs);
 }
        int HookProcCallback(int nCode, IntPtr wParam, IntPtr lParam)
        {
            EventArgsMouse ehargs = null;

            if (nCode >= 0)
            {
                try
                {
                    var hookType        = (CtkEnumConst)wParam;
                    var mouseHookStruct = (CtkMdlHookMouseStruct)Marshal.PtrToStructure(lParam, typeof(CtkMdlHookMouseStruct));

                    short mouseDelta = 0;

                    if (hookType == CtkEnumConst.WM_MOUSEWHEEL)
                    {
                        mouseDelta = (short)((mouseHookStruct.mouseData >> 16) & 0xffff);
                    }

                    ehargs = new EventArgsMouse(hookType, mouseHookStruct.dx, mouseHookStruct.dy, mouseDelta);

                    if (hookType == CtkEnumConst.WM_MOUSEWHEEL)
                    {
                        this.OnMouseWheel(ehargs);
                    }

                    else if (hookType == CtkEnumConst.WM_LBUTTONUP || hookType == CtkEnumConst.WM_RBUTTONUP || hookType == CtkEnumConst.WM_MBUTTONUP)
                    {
                        this.OnMouseUp(ehargs);
                        if (mouseHookStruct.dx == m_LastBTDownX && mouseHookStruct.dy == m_LastBTDownY)
                        {
                            this.OnMouseClick(ehargs);
                        }
                    }
                    else if (hookType == CtkEnumConst.WM_LBUTTONDOWN || hookType == CtkEnumConst.WM_RBUTTONDOWN || hookType == CtkEnumConst.WM_MBUTTONDOWN)
                    {
                        m_LastBTDownX = mouseHookStruct.dx;
                        m_LastBTDownY = mouseHookStruct.dy;
                        this.OnMouseDown(ehargs);
                    }
                    else if (m_OldX != mouseHookStruct.dx || m_OldY != mouseHookStruct.dy)
                    {
                        m_OldX = mouseHookStruct.dx;
                        m_OldY = mouseHookStruct.dy;
                        this.OnMouseMove(ehargs);
                    }
                }
                catch (Exception ex)
                {
                    //給背景執行緒處理, 再出Exception也與原執行緒無關, 可以正常工作
                    ThreadPool.QueueUserWorkItem(delegate { this.OnHookCallbackException(new CtkWinApiEventArgsException()
                        {
                            exception = ex
                        }); });
                }
            }

            if (Monopolize || (ehargs != null && ehargs.Handled))
            {
                return(-1);
            }


            return(CtkUser32Lib.CallNextHookEx(intPtrHook, nCode, wParam, lParam));
        }