public override bool PreProcessMessage(ref Message msg) { if (msg.Msg >= _wm_KEYFIRST && msg.Msg <= _wm_KEYLAST) { var filterKeys = (IVsFilterKeys2)ServiceProvider.GlobalProvider.GetService(typeof(SVsFilterKeys)); var oleMSG = new OLE.Interop.MSG() { hwnd = msg.HWnd, lParam = msg.LParam, wParam = msg.WParam, message = (uint)msg.Msg }; //Ask the shell to do the command mapping for us and without firing off the command. We need to check if this command is one of the //supported commands first before actually firing the command. filterKeys.TranslateAcceleratorEx(new OLE.Interop.MSG[] { oleMSG }, (uint)(__VSTRANSACCELEXFLAGS.VSTAEXF_NoFireCommand | __VSTRANSACCELEXFLAGS.VSTAEXF_UseGlobalKBScope | __VSTRANSACCELEXFLAGS.VSTAEXF_AllowModalState), 0 /*scope count*/, Array.Empty <Guid>() /*scopes*/, out Guid cmdGuid, out uint cmdId, out int fTranslated, out int fStartsMultiKeyChord); if (ShouldRouteCommandBackToVS(cmdGuid, cmdId, fTranslated == 1, fStartsMultiKeyChord == 1)) { return(false); } } return(base.PreProcessMessage(ref msg)); }
public override bool PreProcessMessage(ref Message msg) { if (msg.Msg >= WM_KEYFIRST && msg.Msg <= WM_KEYLAST) { IVsFilterKeys2 filterKeys = (IVsFilterKeys2)ServiceProvider.GlobalProvider.GetService(typeof(SVsFilterKeys)); OLE.Interop.MSG oleMSG = new OLE.Interop.MSG() { hwnd = msg.HWnd, lParam = msg.LParam, wParam = msg.WParam, message = (uint)msg.Msg }; Guid cmdGuid; uint cmdId; int fTranslated; int fStartsMultiKeyChord; //Ask the shell to do the command mapping for us and without firing off the command. We need to check if this command is one of the //supported commands first before actually firing the command. filterKeys.TranslateAcceleratorEx( new OLE.Interop.MSG[] { oleMSG }, (uint)(__VSTRANSACCELEXFLAGS.VSTAEXF_NoFireCommand | __VSTRANSACCELEXFLAGS.VSTAEXF_UseGlobalKBScope | __VSTRANSACCELEXFLAGS.VSTAEXF_AllowModalState), 0 /*scope count*/, new Guid[0] /*scopes*/, out cmdGuid, out cmdId, out fTranslated, out fStartsMultiKeyChord ); if (ShouldRouteCommandBackToVS(cmdGuid, cmdId, fTranslated == 1, fStartsMultiKeyChord == 1)) { return false; } } return base.PreProcessMessage(ref msg); }