IVsUIHierarchyWindow::GetCurrentSelection Method (IntPtr, UInt32, IVsMultiItemSelect^)
Gets the alternate itemID of the current selection when an alternate UIHierarchy is used.
Assembly: Microsoft.VisualStudio.Shell.Interop (in Microsoft.VisualStudio.Shell.Interop.dll)
int GetCurrentSelection( [OutAttribute] IntPtr% ppHier, [OutAttribute] unsigned int% pitemid, [OutAttribute] IVsMultiItemSelect^% ppMIS )
Parameters
- ppHier
-
Type:
System::IntPtr
[out] Pointer to the IVsHierarchy interface of the current project hierarchy.
- pitemid
-
Type:
System::UInt32
[out] Pointer to the identifier for the current project item. If pitemid is set to VSITEMID_SELECTION, the current selection involves multiple items. These items can be accessed using the IVsMultiItemSelect interface pointed to by ppMIS.
- ppMIS
-
Type:
Microsoft.VisualStudio.Shell.Interop::IVsMultiItemSelect^
[out] Pointer to the IVsMultiItemSelect interface to be used to access a multiple selection.
Return Value
Type: System::Int32If the method succeeds, it returns S_OK. If it fails, it returns an error code.
From vsshell.idl:
HRESULT IVsUIHierarchyWindow::GetCurrentSelection( [out] IVsHierarchy ** ppHier, [out] VSITEMID * pitemid, [out] IVsMultiItemSelect ** ppMIS );
When there are no alternate UI hierarchy itemIDs, it is more common to use GetCurrentSelection to get the global currently active hierarchy itemID.
IVsUIHierarchyWindow::GetCurrentSelection is used when the selection within the local UI window has a different hierarchy itemID from the global hierarchy itemID. A UI window pushes a different hierarchy itemID to the global level if grfUIHWF is specified as UIHWF_PropagateAltHierarchyItem in Init.
The Macro Explorer and the Server Explorer are examples of tool windows that use a local UI window hierarchy itemID. In the Macro Explorer and Server Explorer, the IVsTrackSelectionEx implementation specifies the value HIERARCHY_DONTPROPAGATE (defined in vsshell.idl) so the locally selected UI hierarchy itemID does not get propagated to the global level. If HIERARCHY_DONTPROPAGATE is not selected, the local hierarchy itemID can be pushed to the global level.