次の方法で共有


IVsUIHierarchyWindow.GetCurrentSelection Method

Definition

Gets the alternate itemID of the current selection when an alternate UIHierarchy is used.

public:
 int GetCurrentSelection([Runtime::InteropServices::Out] IntPtr % ppHier, [Runtime::InteropServices::Out] System::UInt32 % pitemid, [Runtime::InteropServices::Out] Microsoft::VisualStudio::Shell::Interop::IVsMultiItemSelect ^ % ppMIS);
public int GetCurrentSelection (out IntPtr ppHier, out uint pitemid, out Microsoft.VisualStudio.Shell.Interop.IVsMultiItemSelect ppMIS);
abstract member GetCurrentSelection : nativeint * uint32 * IVsMultiItemSelect -> int
Public Function GetCurrentSelection (ByRef ppHier As IntPtr, ByRef pitemid As UInteger, ByRef ppMIS As IVsMultiItemSelect) As Integer

Parameters

ppHier
IntPtr

nativeint

[out] Pointer to the IVsHierarchy interface of the current project hierarchy.

pitemid
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
IVsMultiItemSelect

[out] Pointer to the IVsMultiItemSelect interface to be used to access a multiple selection.

Returns

If the method succeeds, it returns S_OK. If it fails, it returns an error code.

Remarks

COM Signature

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.

Applies to