Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / Extensibility / October 2006

Tip: Looking for answers? Try searching our database.

EnvDTE.Solution versus EnvDTE.UIHierarchy model

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Browning - 10 Oct 2006 14:14 GMT
Hi there,

Can someone confirm that these two models will always contain the same
hierarchy. In particular, let's say I have an "EnvDTE.ProjectItem" which I
find by traversing "EnvDTE.Solution". I now want to save this to a DB
(table) so I bundle it up as its corresponding string in the hierarchy, say,
"MySolution\MyProject\MyFolder\MyFile.cs", and then save it to the DB (or is
there a more official way of bundling it up). Later on I need to find its
original "EnvDTE.ProjectItem" again so I could manually parse the string and
search through "EnvDTE.Solution" but the "UiHierarchy" model already
provides a canned method for this:

string MyFile = "MySolution\MyProject\MyFolder\MyFile.cs";
ProjectItem MyProjectItem =
(ProjectItem)DTE2.ToolWindows.SolutionExplorer.GetItem(MyFile).Object;

This will only work however if the "EnvDTE.Solution" model and the
"EnvDTE.UiHierarchy" models provide the same hierarchy which I assume is
true. Can someone confirm this. Thanks.
Carlos J. Quintero [VB MVP] - 10 Oct 2006 14:51 GMT
Yes, I would say that they are the same. The Solution Explorer uses
UIHierarchy, but each UIHierarchyItem has an Object property that returns a
Solution, Project or ProjectItem.

Also, my MZ-Tools add-in uses an output window that has to show the same
hierarchy than the Solution Explorer and for that  I traverse the Solution /
Project / ProjectItems.

Signature

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com

> Hi there,
>
[quoted text clipped - 15 lines]
> "EnvDTE.UiHierarchy" models provide the same hierarchy which I assume is
> true. Can someone confirm this. Thanks.
John Browning - 10 Oct 2006 15:17 GMT
> Yes, I would say that they are the same. The Solution Explorer uses
> UIHierarchy, but each UIHierarchyItem has an Object property that returns
[quoted text clipped - 3 lines]
> hierarchy than the Solution Explorer and for that  I traverse the Solution
> / Project / ProjectItems.

Thanks for the feedback. It really confirms a small blurb on the subject
which I found in a MSFT Press book written by several experienced MSFT
developers. They all but confirm that the models are identical but I still
had some lingering doubt (based on some of their wording but they
effectively confirm what you said). BTW, in your own tree view, do you use
the same icons as seen in Solution Explorer. I recently wrote my own tree
view for this as well and wanted to rely on the solution
"UIHierarchy.Parent.HWnd" member to get hold of these icons. The latter
member is documented for internal MSFT use only however so there's no
guarantee that it's reliable or even points to a traditional Windows handle.
Presumably it does but it's "use at your own risk". Do you have any
experience with this. Thanks again.
Carlos J. Quintero [VB MVP] - 11 Oct 2006 09:51 GMT
Hi John,

I am using my own pictures not the ones of the Solution Explorer window. It
could be that the Solution Explorer window is not even created when your
add-in executes its features, so you can't rely on it, not to mention that
IIRC Window.HWnd returns 0 for all child windows (it only returns the actual
handle for DTE.MainWindow.HWnd).

Signature

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com

> BTW, in your own tree view, do you use the same icons as seen in Solution
> Explorer. I recently wrote my own tree view for this as well and wanted to
[quoted text clipped - 3 lines]
> Windows handle. Presumably it does but it's "use at your own risk". Do you
> have any experience with this. Thanks again.
John Browning - 12 Oct 2006 14:17 GMT
> I am using my own pictures not the ones of the Solution Explorer window.
> It could be that the Solution Explorer window is not even created when
> your add-in executes its features, so you can't rely on it, not to mention
> that IIRC Window.HWnd returns 0 for all child windows (it only returns the
> actual handle for DTE.MainWindow.HWnd).

Thanks for the info. Note that I was going to dig into this handle using
Win32 methods but if it might not even be created (not sure why or whether I
can always create it on-the-fly) then I might be taking a bigger chance than
using the handle at all (given that it's "for internal use only").

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.