Exemple #1
0
        public bool TranslateAccelerator(ref MSG msg)
        {
            var message = new Message
            {
                hwnd    = msg.hwnd,
                message = (int)msg.message,
                wParam  = msg.wParam,
                lParam  = msg.lParam,
                time    = (int)msg.time,
                pt_x    = msg.pt.x,
                pt_y    = msg.pt.y
            };

            var used = ComponentDispatcher.RaiseThreadMessage(ref message);

            if (used)
            {
                msg.message = (uint)message.message;
                msg.wParam  = message.wParam;
                msg.lParam  = message.lParam;

                return(true);
            }

            return(false);
        }
Exemple #2
0
        public async Task <int> TranslateAcceleratorAsync(MSG msg)
        {
            var message = new Message
            {
                hwnd    = msg.hwnd,
                message = (int)msg.message,
                wParam  = msg.wParam,
                lParam  = msg.lParam,
                time    = (int)msg.time,
                pt_x    = msg.pt.x,
                pt_y    = msg.pt.y
            };

            var used = ComponentDispatcher.RaiseThreadMessage(ref message);

            if (used)
            {
                msg.message = (uint)message.message;
                msg.wParam  = message.wParam;
                msg.lParam  = message.lParam;

                return(VSConstants.S_OK);
            }

            if (_propertyPageSite != null)
            {
                await _projectThreadingService.SwitchToUIThread();

                return(_propertyPageSite.TranslateAccelerator(new MSG[] { msg }));
            }

            return(VSConstants.S_OK);
        }
        protected override bool PreProcessMessage(ref Message msg)
        {
            // send translated message via component dispatcher
            MSG dispatchMsg = new MSG();

            dispatchMsg.hwnd    = msg.HWnd;
            dispatchMsg.lParam  = msg.LParam;
            dispatchMsg.wParam  = msg.WParam;
            dispatchMsg.message = msg.Msg;
            if (ComponentDispatcher.RaiseThreadMessage(ref dispatchMsg) == true)
            {
                msg.Result = (IntPtr)1;
                return(true);
            }
            return(base.PreProcessMessage(ref msg));
        }
Exemple #4
0
        public int TranslateAccelerator(VsMsg[] pMsg)
        {
            if (pMsg == null || pMsg.Length == 0)
            {
                throw new ArgumentNullException(nameof(pMsg));
            }

            var xMsg     = pMsg[0];
            var xMessage = new Message();

            xMessage.hwnd    = xMsg.hwnd;
            xMessage.message = (int)xMsg.message;
            xMessage.wParam  = xMsg.wParam;
            xMessage.lParam  = xMsg.lParam;
            xMessage.time    = (int)xMsg.time;
            xMessage.pt_x    = xMsg.pt.x;
            xMessage.pt_y    = xMsg.pt.y;

            var xUsed = ComponentDispatcher.RaiseThreadMessage(ref xMessage);

            if (xUsed)
            {
                xMsg.message = (uint)xMessage.message;
                xMsg.wParam  = xMessage.wParam;
                xMsg.lParam  = xMessage.lParam;

                return(VSConstants.S_OK);
            }

            int xResult = 0;

            if (mPropertyPageSite != null)
            {
                ProjectThreadingService.SwitchToUIThread();
                xResult = mPropertyPageSite.TranslateAccelerator(pMsg);
            }

            return(xResult);
        }
        protected override bool PreProcessMessage(ref Message msg)
        {
            // trap keyboard messages if window has focus
            if (msg.Msg == 256)
            {
                if (msg.WParam == (IntPtr)17)
                {
                    isControlKeyDepressed = true;
                    isOtherKeyDepressed   = false;
                }
                else if (msg.WParam == (IntPtr)16)
                {
                    isShifKeyDepressed  = true;
                    isOtherKeyDepressed = false;
                }
                else
                {
                    if (isOtherKeyDepressed)
                    {
                        isControlKeyDepressed = false;
                        isShifKeyDepressed    = false;
                    }
                    isOtherKeyDepressed = true;
                    if (isControlKeyDepressed)
                    {
                        if (isShifKeyDepressed)
                        {
                            switch (msg.WParam.ToInt64())
                            {
                            //case 65: // Ctrl+Shit+A command
                            //case 67: // Ctrl+Shit+C command
                            //case 78: // Ctrl+Shit+N command
                            //case 79: // Ctrl+Shit+O command
                            //case 83: // Ctrl+Shit+S command
                            //case 85: // Ctrl+Shit+U command
                            //case 88: // Ctrl+Shit+X command
                            //    isCommandCombinationDepressed = true;
                            //    break;
                            default:
                                isCommandCombinationDepressed = false;
                                break;
                            }
                        }
                        else
                        {
                            switch (msg.WParam.ToInt64())
                            {
                            case 70:     // Ctrl+E command
                                isCommandCombinationDepressed = true;
                                break;

                            default:
                                isCommandCombinationDepressed = false;
                                break;
                            }
                        }
                    }
                    else
                    {
                        isCommandCombinationDepressed = false;
                    }
                }

                if (isCommandCombinationDepressed == true)
                {
                    // send translated message via component dispatcher
                    MSG dispatchMsg = new MSG();
                    dispatchMsg.hwnd    = msg.HWnd;
                    dispatchMsg.lParam  = msg.LParam;
                    dispatchMsg.wParam  = msg.WParam;
                    dispatchMsg.message = msg.Msg;
                    ComponentDispatcher.RaiseThreadMessage(ref dispatchMsg);
                    msg.Result = (IntPtr)1;
                    return(true);
                }
            }
            return(base.PreProcessMessage(ref msg));
        }