示例#1
0
        private int MouseHookProc(int code, IntPtr wparam, IntPtr lparam)
        {
            WinApi.MOUSEHOOKSTRUCT mousehookstruct = (WinApi.MOUSEHOOKSTRUCT)Marshal.PtrToStructure(lparam, typeof(WinApi.MOUSEHOOKSTRUCT));

            const string messageLogFormat = "({0}; {1})\tbutton: {2}\r\n";

            string mouseButton = string.Empty;

            //if(code == WinApi.HC_ACTION)
            //{
            switch ((int)wparam)
            {
            case WinApi.WM_LBUTTONDOWN:
                mouseButton = "Left";
                break;

            case WinApi.WM_RBUTTONDOWN:
                mouseButton = "Right";
                break;

            default:
                mouseButton = "None";
                break;
            }
            //}
            messageLogTextBox.Text += string.Format(messageLogFormat, mousehookstruct.pt.x, mousehookstruct.pt.y, mouseButton);

            return(CallNextHookEx(_localMouseHook.HookHandle, code, wparam, lparam));
        }
示例#2
0
 protected override bool HandleHookEvent(IntPtr wParam, IntPtr lParam)
 {
     if (GetMouseMessage == null)
     {
         return(false);
     }
     if (!_messagesToIntercept.Contains((uint)wParam))
     {
         return(false);
     }
     WinApi.MOUSEHOOKSTRUCT ms = (WinApi.MOUSEHOOKSTRUCT)Marshal.PtrToStructure(lParam, typeof(WinApi.MOUSEHOOKSTRUCT));
     return(GetMouseMessage((WinApi.WindowsMessageMouse)wParam, ms));
 }
示例#3
0
文件: Plug.cs 项目: devjerome/3P
        private static bool MouseMessageHandler(WinApi.WindowsMessageMouse message, WinApi.MOUSEHOOKSTRUCT mouseStruct)
        {
            switch (message)
            {
            // middle click : go to definition
            case WinApi.WindowsMessageMouse.WM_MBUTTONDOWN:
                //if (Npp.GetScintillaRectangle().Contains(Cursor.Position)) {
                if (KeyboardMonitor.GetModifiers.IsCtrl)
                {
                    Npp.GoBackFromDefinition();
                }
                else
                {
                    ProMisc.GoToDefinition(true);
                }
                return(true);

            //break;
            // (CTRL + ) Right click : show main menu
            case WinApi.WindowsMessageMouse.WM_RBUTTONUP:
                if (KeyboardMonitor.GetModifiers.IsCtrl)
                {
                    // we need the cursor to be in scintilla but not on the application or the auto-completion!
                    if ((!Appli.IsVisible || !Appli.IsMouseIn()) &&
                        (!InfoToolTip.IsVisible || !InfoToolTip.IsMouseIn()) &&
                        (!AutoComplete.IsVisible || !AutoComplete.IsMouseIn()))
                    {
                        AppliMenu.ShowMainMenuAtCursor();
                        return(true);
                    }
                }
                break;
            }

            // HACK: The following is to handle the MOVE/RESIZE event of npp's window.
            // It would be cleaner to use a WndProc bypass but it costs too much... this is a cheaper solution
            switch (message)
            {
            case WinApi.WindowsMessageMouse.WM_NCLBUTTONDOWN:
                if (!WinApi.GetWindowRect(Npp.HandleScintilla).Contains(Cursor.Position))
                {
                    MouseMonitor.Instance.Add(WinApi.WindowsMessageMouse.WM_MOUSEMOVE);
                }
                break;

            case WinApi.WindowsMessageMouse.WM_LBUTTONUP:
            case WinApi.WindowsMessageMouse.WM_NCLBUTTONUP:
                if (MouseMonitor.Instance.Remove(WinApi.WindowsMessageMouse.WM_MOUSEMOVE))
                {
                    if (OnNppWindowsMove != null)
                    {
                        OnNppWindowsMove();
                    }
                }
                break;

            case WinApi.WindowsMessageMouse.WM_MOUSEMOVE:
                if (OnNppWindowsMove != null)
                {
                    OnNppWindowsMove();
                }
                break;
            }

            return(false);
        }