/// <include file='doc\PropertyBrowserService.uex' path='docs/doc[@for="PropertyBrowserService.PbrsCommandTarget.NativeMethods.IOleCommandTarget.QueryStatus"]/*' /> /// <devdoc> /// Delegate to the current user context command target for undo/redo commands, /// otherwise call the default target. /// </devdoc> int NativeMethods.IOleCommandTarget.QueryStatus(ref Guid pguidCmdGroup,int cCmds, NativeMethods._tagOLECMD prgCmds,IntPtr pCmdText) { if (pguidCmdGroup == ShellGuids.VSStandardCommandSet97) { switch (prgCmds.cmdID) { case VSStandardCommands.cmdidUndo: if (pbrsSvc.GetPropertyBrowser().CanUndo) { prgCmds.cmdf = (int)(NativeMethods.tagOLECMDF.OLECMDF_ENABLED | NativeMethods.tagOLECMDF.OLECMDF_SUPPORTED); return NativeMethods.S_OK; } goto case VSStandardCommands.cmdidMultiLevelUndo; case VSStandardCommands.cmdidMultiLevelUndo: case VSStandardCommands.cmdidMultiLevelUndoList: case VSStandardCommands.cmdidRedo: case VSStandardCommands.cmdidMultiLevelRedo: case VSStandardCommands.cmdidMultiLevelRedoList: // get the current context and delegate to it NativeMethods.IOleCommandTarget currentTarget = GetCurrentContextTarget(); if (currentTarget != null && currentTarget != this) { int hr = currentTarget.QueryStatus(ref pguidCmdGroup, 1, prgCmds, pCmdText); return hr; } break; case VSStandardCommands.cmdidPaste: if (pbrsSvc.GetPropertyBrowser().CanPaste) { prgCmds.cmdf = (int)(NativeMethods.tagOLECMDF.OLECMDF_ENABLED | NativeMethods.tagOLECMDF.OLECMDF_SUPPORTED); } else { prgCmds.cmdf = (int)(NativeMethods.tagOLECMDF.OLECMDF_SUPPORTED); } return NativeMethods.S_OK; case VSStandardCommands.cmdidCut: if (pbrsSvc.GetPropertyBrowser().CanCut) { prgCmds.cmdf = (int)(NativeMethods.tagOLECMDF.OLECMDF_ENABLED | NativeMethods.tagOLECMDF.OLECMDF_SUPPORTED); } else { prgCmds.cmdf = (int)(NativeMethods.tagOLECMDF.OLECMDF_SUPPORTED); } return NativeMethods.S_OK; case VSStandardCommands.cmdidCopy: if (pbrsSvc.GetPropertyBrowser().CanCopy) { prgCmds.cmdf = (int)(NativeMethods.tagOLECMDF.OLECMDF_ENABLED | NativeMethods.tagOLECMDF.OLECMDF_SUPPORTED); } else { prgCmds.cmdf = (int)(NativeMethods.tagOLECMDF.OLECMDF_SUPPORTED); } return NativeMethods.S_OK; } } // just call down to the base. Debug.Assert(baseCommandTarget != this, "we're calling ourselves and will recurse!"); return baseCommandTarget.QueryStatus(ref pguidCmdGroup, cCmds, prgCmds, pCmdText); }
/// <include file='doc\MenuCommandService.uex' path='docs/doc[@for="MenuCommandService.NativeMethods.IOleCommandTarget.QueryStatus"]/*' /> /// <devdoc> /// Inquires about the status of a command. A command's status indicates /// it's availability on the menu, it's visibility, and it's checked state. /// /// The exception thrown by this method indicates the current command status. /// </devdoc> int NativeMethods.IOleCommandTarget.QueryStatus(ref Guid pguidCmdGroup, int cCmds, NativeMethods._tagOLECMD prgCmds, /* _tagOLECMDTEXT */ IntPtr pCmdTextInt) { int hr = NativeMethods.S_OK; MenuCommand cmd = FindCommand(pguidCmdGroup, prgCmds.cmdID, ref hr); if (cmd != null && NativeMethods.Succeeded(hr)) { prgCmds.cmdf = cmd.OleStatus; // If this is a verb, update the text in the command. // if (cmd is DesignerVerb) { NativeMethods.tagOLECMDTEXT.SetText(pCmdTextInt, ((DesignerVerb)cmd).Text); } // SBurke, if the flags are zero, the shell prefers // that we return not supported, or else no one else will // get asked // if (prgCmds.cmdf == 0) { hr = NativeMethods.OLECMDERR_E_NOTSUPPORTED; } } return(hr); }
/// <include file='doc\VsWindowPane.uex' path='docs/doc[@for="VsWindowPane.NativeMethods.IOleCommandTarget.QueryStatus"]/*' /> /// <devdoc> /// This is called by Visual Studio when it needs the status of our menu commands. There /// is no need to override this method. If you need access to menu commands use /// IMenuCommandService. /// </devdoc> int NativeMethods.IOleCommandTarget.QueryStatus(ref Guid guidGroup, int nCmdId, NativeMethods._tagOLECMD oleCmd, IntPtr oleText) { NativeMethods.IOleCommandTarget tgt = (NativeMethods.IOleCommandTarget)GetService((typeof(NativeMethods.IOleCommandTarget))); if (tgt != null) { return(tgt.QueryStatus(ref guidGroup, nCmdId, oleCmd, oleText)); } else { return(NativeMethods.OLECMDERR_E_NOTSUPPORTED); } }