How can I use UIHierarchy.get_SelectedITems() in C++?
Visual Basic Code ::
Dim UIH As UIHierarchy =
applicationObject.Windows.Item(Constants.vsWindowKindSolutionExplorer).Object
Dim uiitem As UIHierarchyItem
For Each uiitem In UIH.SelectedItems
If TypeOf uiitem.Object Is Project Then
project = uiitem.Object
End If
Next
C++ Code (incompleted) ::
CComPtr<EnvDTE::Windows> pWindows;
CComPtr<EnvDTE::UIHierarchy> pUIHierarchy;
m_pDTE->get_Windows( &pWindows );
LONG lItemCount, i;
pWindows->get_Count( &lItemCount );
for( i = 1; i <= lItemCount; i++ ) {
CComPtr<EnvDTE::Window> pWindow;
EnvDTE::vsWindowType a_vsWindowType;
pWindows->Item( CComVariant( i ), &pWindow );
pWindow->get_Type( &a_vsWindowType );
if( a_vsWindowType == EnvDTE::vsWindowTypeSolutionExplorer ) {
pWindow->get_Object( (IDispatch **) &pUIHierarchy );
break;
}
}
pUIHierarchy->get_SelectedItems( (VARIANT *) ??????? );
If you know how to do in C/C++, please let me know.
Many thanks in advance.
Matthew Etter - 23 Aug 2005 23:07 GMT
I would recommend that you get the IVsMonitorSelection service from the
Shell. You can then simply call GetCurrentSelection.
If you're not using the VSIP interfaces, and just the EnvDTE stuff, you'll
find that get_SelectedItems returns a SelectedItems interface, which is just
a collection of SelectedItem interfaces. The VARIANT will contain the
IUnknown (or IDispatch) of the SelectedItems collection object. Depending on
how you're getting your C++ header (#import, or via tlbexp), you may see
these interfaces prefixed with underscores (eg _SelectedItem).
And I don't think you need to find the reference to the Project to do this.
You should be able to use the DTE.SelectedItems property to get the same
results.
> How can I use UIHierarchy.get_SelectedITems() in C++?
>
[quoted text clipped - 34 lines]
>
> Many thanks in advance.