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 / June 2004

Tip: Looking for answers? Try searching our database.

Addin and CommandBars

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rick Strahl [MVP] - 29 Jun 2004 04:06 GMT
Is it possible to do the following:

1 - get more than one command bar to show up for an Addin?
I get one button to work, but I'm unable to get a second button to display.

2 - Assign a shortcut key to a bar. I think Set_accName and Set accValue
might
  fit the bill but I've been unable to find out what the first parameter to
  these thigns is supposed to be.

As to #1 I have something like this:

//if(connectMode == Extensibility.ext_ConnectMode.ext_cm_Startup)
if(connectMode == Extensibility.ext_ConnectMode.ext_cm_UISetup)
{
  object []contextGUIDS = new object[] { };
  object []contextGUIDS2 = new object[] { };
  Commands commands = applicationObject.Commands;
  _CommandBars commandBars = applicationObject.CommandBars;

  try
  {
     Command command = commands.AddNamedCommand(addInInstance,
"HelpBuilderAutomation", "HelpBuilderAutomation",
                                                   "Executes the command
for HelpBuilderAutomation", true, 59,
                                             ref contextGUIDS,

(int)vsCommandStatus.vsCommandStatusSupported+

(int)vsCommandStatus.vsCommandStatusEnabled);

     CommandBar commandBar = (CommandBar)commandBars["Help"];
     CommandBarControl commandBarControl = command.AddControl(commandBar,
1);

     Command command2 = commands.AddNamedCommand(addInInstance,
"HelpBuilderAutomation2", "HelpBuilderAutomation2",
        "Executes the command for HelpBuilderAutomation2",true, 59,
        ref contextGUIDS2,
(int)vsCommandStatus.vsCommandStatusSupported+(int)vsCommandStatus.vsCommand
StatusEnabled);

     command2.AddControl(commandBar,1);

  }
  catch(System.Exception /*e*/)
  {
  }
}

No error occurs, but the second bar doesn't show up... That is until I
unregister the Add-in. At that point both bars show up...

+++ Rick ---

Signature

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
----------------------------------
Making waves on the Web

Carlos J. Quintero [MVP] - 29 Jun 2004 14:29 GMT
There are several things involved here.

- First, terminology: you have CommandBars and CommandBarControls (or
buttons), which you are using indistinctly while they are quite different.

- You can create any number of command bars and command bar controls for any
add-in.

- In order to support commands, your connect class must implement
EnvDTE.IDTCommandTarget, and in the QueryStatus method you must return

StatusOption = vsCommandStatus.vsCommandStatusEnabled |
vsCommandStatus.vsCommandStatusSupported;

if the passed command name is one of your add-in.

- The ext_ConnectMode.ext_cm_UISetup flag is passed only once to your
add-in. But since the commands are created in the debugged IDE and you close
it before the first IDE (The one with the addin code), when you close this
first instance its overwrites changes of the second IDE and therefore the
commands are removed. Also, if you wrote the code to add the first control,
executed it, the UISetup flag was passed and later you added the code to add
the second control, the UISetup flag is not passed again and your second
control does not show. Maybe this explains you behaviour. You can force a
UISetup again reinstalling the add-in or changing manually the
CommandPreload registry entry of your addin to reset it from 1 to 0
(assuming that your addin uses machine installation, not user-installation,
which uses a different registry key).

-You can bind keyboard shortcuts to commands using the Command.Bindings
property, assuming that the user is not using a predefined keyboard mapping
scheme but a copy (Options window, Keyboard node).

Signature

Carlos J. Quintero (Visual Developer - .NET MVP)

FAQs, Knowledge Base, Files, Docs, Articles, Utilities, etc. for .NET
addins:
http://groups.yahoo.com/group/vsnetaddin/ (free join)

> Is it possible to do the following:
>
[quoted text clipped - 36 lines]
>          "Executes the command for HelpBuilderAutomation2",true, 59,
>          ref contextGUIDS2,

(int)vsCommandStatus.vsCommandStatusSupported+(int)vsCommandStatus.vsCommand
> StatusEnabled);
>
[quoted text clipped - 10 lines]
>
> +++ Rick ---
Rick Strahl [MVP] - 29 Jun 2004 21:13 GMT
Carlos,

Thanks so much for all of your help.

The missing link here was the QueryStatus and enabling of the commands. Now
I get both buttons and they are firing!

I ended up buying a book which should arrive in a couple of days. Hopefully
this will let me
get a little more of the big picture of interrelated parts of this process.

I sure hope MS goes through this in the future and provides a cleaner more
object based way
using pure .Net code to hook into these shells.

Thanks again for your help, Carlos.

+++ Rick ---

Signature

Rick Strahl
West Wind Technologies
http://www.west-wind.com/
http://www.west-wind.com/weblog/
----------------------------------
Making waves on the Web

> There are several things involved here.
>
[quoted text clipped - 71 lines]
> >          "Executes the command for HelpBuilderAutomation2",true, 59,
> >          ref contextGUIDS2,

(int)vsCommandStatus.vsCommandStatusSupported+(int)vsCommandStatus.vsCommand
> > StatusEnabled);
> >
[quoted text clipped - 10 lines]
> >
> > +++ Rick ---

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.