Queries the object for the command status.
Assembly: Microsoft.VisualStudio.Shell.Interop (in Microsoft.VisualStudio.Shell.Interop.dll)
int QueryStatusCommand( uint itemid, ref Guid pguidCmdGroup, uint cCmds, OLECMD prgCmds, IntPtr pCmdText )
- Type: System.UInt32
[in] Identifier of the item affected by this command. For a list of itemid values, see VSITEMID. For single selection, this is the actual item ID. For multiple selections, set itemid equal to VSITEMID_SELECTION.
- Type: System.Guid
[in, unique] Pointer to a unique identifier of the command group. The pguidCmdGroup parameter can be null to specify the standard group.
- Type: System.UInt32
[in] The number of commands in the prgCmds array.
- Type: Microsoft.VisualStudio.OLE.Interop.OLECMD
[in, out, size_is(cCmds)] A caller-allocated array of OLECMD structures that indicate the commands for which the caller requires status information. This method fills the cmdf member of each structure with values taken from the OLECMDF enumeration.
HRESULT IVsUIHierarchy::QueryStatusCommand( [in] VSITEMID itemid, [in, unique] const GUID * pguidCmdGroup, [in] ULONG cCmds, [in, out, size_is(cCmds)] OLECMD prgCmds, [in, out, unique] OLECMDTEXT *pCmdText );
This method is similar to the M:Microsoft.VisualStudio.OLE.Interop.IOleCommandTarget.Exec(System.Guid@,System.UInt32,System.UInt32,System.IntPtr,System.IntPtr) method, which does not support hierarchies. The ExecCommand method additionally includes the itemid parameter, which identifies the hierarchy item to which the command applies.
The environment executes this method when the UI hierarchy window has focus. The UI hierarchy window delegates all menu or toolbar commands to the UIHierarchy object that is the common parent for the selection. This provides the UIHierarchy object the option to handle commands that only apply when the UI hierarchy window has focus. Examples include the Delete and Remove commands.
Do not also handle these commands using the IOleCommandTarget interface on which QueryInterface can be run from the IVsHierarchy interface. The IOleCommandTarget of the active project is included in the usual command routing of the environment, even when another window (for example, a document window) has focus.
If the UI hierarchy window is not the active window, but it is still the active hierarchy, meaning that it is the last hierarchy to have been selected, then any commands that involve the active hierarchy are sent through the IOleCommandTarget interface instead of the IVsUIHierarchy interface. For example, if the selection is changed from the Solution Explorer to the task list, then the Solution Explorer is the active hierarchy, but the active window is the task list. In this case, any commands that are related to the active hierarchy, such as adding an item to the project, are sent through the IOleCommandTarget interface.
Commands like adding a project item should not be handled by the IVsUIHierarchy methods because they will not be available from outside of the hierarchy window. Only use IVsUIHierarchy to handle commands that require the UI Hierarchy window to have focus, or that act on a specific item within the hierarchy.
- Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.