Home Dashboard Directory Help

Wrong default vsCommandStyle for CommandBarButtons created from add-ins by Carlos J. Quintero


 as Won't Fix Help for as Won't Fix

Sign in
to vote
Type: Bug
ID: 294701
Opened: 8/23/2007 2:07:52 AM
Access Restriction: Public
User(s) can reproduce this bug


When an add-in creates a CommandBarButton from a command using EnvDTE.Command.AddControl(...), one would expect a default style as follows:

- For toolbars, only picture (without text)
- For menus, picture + text

The EnvDTE80.Commands2.AddNamedCommand2 function allows to specify (or not) the default style for buttons created for that commands in the optional CommandStyle parameter, but it happens the following:

- If you don't supply it (you can do it because it is not mandatory), then buttons created on a toolbar shows not only picture but also text. This is not desirable, since on a toolbar most buttons show only picture without text.

- If you supply it with the value vsCommandStyle.vsCommandStylePict, then buttons created on a menu shows text (which of course makes sense), but it does not show the picture!

The bottom line: you are forced to cast the CommandBarControl returned by Command.AddControl to CommandBarButton and then adjust the CommandBarButton.Style property. It would be very helpful if you could avoid this step since Visual Studio extensibility is hard and these things don't contribute to make it easy. Furthermore, forcing that step in an add-in with dozens of buttons causes a small delay during the loading of the add-in that could be avoided.

I suggest two easy solutions:

1) Add a vsCommandStyle.vsCommandStyleAutomatic enum value and figure out the best style: Picture+Text on commandbars that are menus and only picture on commandbars that are toolbars.

2) If it is too late to add such value, make that when you don't supply the vsCommandStyle parameter value to behave in that "automatic" guessing.
Sign in to post a comment.
Posted by Microsoft on 8/30/2007 at 4:16 PM
Thank you for your feedback. We are not seeing all of the symptoms described in the upcoming release of Visual Studio (Codename Orcas), but are seeing some. It is too late to get fixes for this in the upcoming release though, and we will consider this for future releases.
Thank you,
Visual Studio Platform Team.
Posted by Microsoft on 8/23/2007 at 4:41 PM
Thanks for your feedback. We have reproduced this bug on Visual Studio 2008 Beta 2, and we are sending this bug to the appropriate group within the VisualStudio Product Team for triage and resolution.

Thank you,
Visual Studio Product Team.
Sign in to post a workaround.