Is it possible to add a button to the Solution Explorer Toolbar using an Addin
-
Thursday, April 15, 2010 6:45 AM
Hi,
I could not understand if you can add a button to the Solution Explorer Toolbar from an Addin (Not a right click option). The examples that I have found show how to do it using a VSPackage. If it possible to do it in an Addin please provide some example.
Thanks
All Replies
-
Thursday, April 15, 2010 9:26 AM
Hi,
This is possible and can be done...
You said you have found some examples doing it using VSpackage can you please forward them so that i can look into them and try solve this issue.
-
Thursday, April 15, 2010 9:53 AMModerator
It should be possible using the following approach:
1) Get the EnvDTE.Window that belongs to the Solution Explorer.
2) Cast it from EnvDTE.Window to EnvDTE80.Window2 in order to get access to the new EnvDTE80.Window2.CommandBars property.
3) Locate the CommandBar in the collection.
4) Once you have the CommandBar, use Command.AddControl(commandBar)
See the approach and a possible bug (not sure if fixed now) here:
MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/- Marked As Answer by Chao KuoModerator Friday, April 16, 2010 7:17 AM
-
Thursday, April 15, 2010 10:15 AM
Hi Carlos,
In your solution: What determines if the command is added to the toolbar or if it added to the context menu?
regards,
-
Thursday, April 15, 2010 10:20 AM
Hi Sparse Communications,
See this video and the code that comes with it: http://msdn.microsoft.com/en-us/vstudio/bb507747.aspx
Regards,
- Edited by Itzhak Kasovitch Thursday, April 15, 2010 10:20 AM type
-
Thursday, April 15, 2010 10:25 AMModerator
The step #3, locating the commandbar in the collection. First of all, Window2.Commandbars doesn't include the commandbar context menu (that you would have to get through DTE.CommandBars). Second, the Window2.Commandbars actually contains two toolbar items which are named "Explorer" and "System". The first one is the one that you would need to use.
Unfortunately I have done some tests (because I was somewhat interested in this area long time ago and your post resurrected the interest) and I have found that it won't be possible from an add-in because:
- In VS 2005 the control is added but when removed it remains there disabled. Neither removing the CommandBarControl nor deleting the command that created it removes the button.
- In VS 2008 you get:
System.UnauthorizedAccessException: Access denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
- In VS 2010 you get the more explicit error:
System.UnauthorizedAccessException: Controls cannot be added to a Toolwindow toolbar.
MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/- Proposed As Answer by Carlos J. QuinteroMVP, Moderator Thursday, April 15, 2010 10:26 AM
- Marked As Answer by Itzhak Kasovitch Thursday, April 15, 2010 11:37 AM
- Edited by Carlos J. QuinteroMVP, Moderator Thursday, April 15, 2010 1:03 PM fix
-
Thursday, April 15, 2010 10:29 AM
Hi Carlos,
So I should use a VSPackage for this mission?
Thanks,
-
Thursday, April 15, 2010 10:53 AM
Hi Itzhak,
Thanks for teh link that you have sent but can you send me in the link for teh video of how should i created the set up and register into the registry of the package credted.
thanks,
vamsi
-
Thursday, April 15, 2010 10:59 AM
Hi Sparse Communications,
when you debug this message it loads VS with the Experimental Hive. You just press F5 to debug, that's it. Of course you should have VS SDK on your machine.
regards,
-
Thursday, April 15, 2010 12:11 PM
Hi Itzhak ,
Thanks for your reply but actually what i wanted to do is:
I need to create a add-in/plug-in vs 2010/vs 2008 which would alter the tab format layout similar to http://www.tabsstudio.com/.So an you people let me know how and where i need to start the process from
Using some videos we have installed sdk add in and we have selected a "visual Studio Shell Isolated " template from the extensibility features in the new project section .Then we have created a package and created a set up for it. When we run the package we are able to change the IDE of the visual studio but when the set up is installed successfully and it is registered successfully in the system registry under the packages ,we are not able to see those changes in the actual vs IDE after completion of the set up.
So can you please suggest me if at all my approach is correct or not if its correct please suggest me how do i need to proceed further with this issue or do i need to proceed in another way so that i can achieve the required task. Please let me know .
Can you please suggest me how i could achieve this
Regards,
vamsi. -
Thursday, April 15, 2010 12:11 PM
Hi Itzhak ,
Thanks for your reply but actually what i wanted to do is:
I need to create a add-in/plug-in vs 2010/vs 2008 which would alter the tab format layout similar to http://www.tabsstudio.com/.So an you people let me know how and where i need to start the process from
Using some videos we have installed sdk add in and we have selected a "visual Studio Shell Isolated " template from the extensibility features in the new project section .Then we have created a package and created a set up for it. When we run the package we are able to change the IDE of the visual studio but when the set up is installed successfully and it is registered successfully in the system registry under the packages ,we are not able to see those changes in the actual vs IDE after completion of the set up.
So can you please suggest me if at all my approach is correct or not if its correct please suggest me how do i need to proceed further with this issue or do i need to proceed in another way so that i can achieve the required task. Please let me know .
Can you please suggest me how i could achieve this
Regards,
vamsi. -
Thursday, April 15, 2010 1:02 PMModeratorI am not expert in packages, but certainly an add-in can't do it so you need to try the SDK/package approach.
MZ-Tools: Productivity add-ins for Visual Studio: http://www.mztools.com. My blog about developing add-ins: http://msmvps.com/blogs/carlosq/ -
Thursday, April 15, 2010 1:16 PM
Hi,
Yes we have taken the same approach that is we have selected a "visual Studio Shell Isolated " template from the extensibility features in the new project section .Then we have created a package and created a set up for it. When we run the package we are able to change the IDE of the visual studio but when the set up is installed successfully and it is registered successfully in the system registry under the packages ,we are not able to see those changes in the actual vs IDE after completion of the set up.
so can you please let me know the procedure to register the set up so that it actually changes the vs IDE.
regards,
vamsi.
-
Friday, April 16, 2010 7:36 AM
Hi vamsi,
I am new to this subject too and unfortunately cannot help you. I suggest that you ask your question in your own thread and maybe somebody that has the knowledge will help you.
Regards,
-
Monday, July 19, 2010 7:26 PMI'm interested in adding a button to the Solution Explorer. All I want it to do is close ALL expanded projects within the solution explorer. Is there a better way to do this than adding a button.
-
Tuesday, July 20, 2010 5:45 AMYou can do the same thing using a keyboard shortcut.

