Note that there are some explanatory texts on larger screens.

plurals
  1. POVS2008 Addin add to menu
    primarykey
    data
    text
    <p>I'm using this code to add an item to the code window right click menu:</p> <pre><code>public void OnConnection( object application, ext_ConnectMode connectMode, object addInInst, ref Array custom) { _applicationObject = (DTE2)application; _addInInstance = (AddIn)addInInst; object[] contextGUIDS = new object[] { }; Command codeWindowCommand = null; CommandBarControl codeWindowButton; CommandBar codeCommandBar; CommandBars commandBars; try { codeWindowCommand = _applicationObject.Commands.Item( _addInInstance.ProgID + "." + CODEWINDOW_COMMAND_NAME, 0); } catch { } if (codeWindowCommand == null) { codeWindowCommand = _applicationObject.Commands.AddNamedCommand( _addInInstance, CODEWINDOW_COMMAND_NAME, CODEWINDOW_COMMAND_NAME, "Pastebin selected code", true, 18, ref contextGUIDS, (int)vsCommandStatus.vsCommandStatusSupported + (int)vsCommandStatus.vsCommandStatusEnabled); } commandBars = (CommandBars)_applicationObject.CommandBars; codeCommandBar = commandBars["Code Window"]; codeWindowButton = (CommandBarControl)codeWindowCommand.AddControl( codeCommandBar, codeCommandBar.Controls.Count + 1); codeWindowButton.Caption = "Text for button"; codeWindowButton.TooltipText = "Tooltip for button"; } </code></pre> <p>and the addin is set to autostart. However each time the run VS2008 it adds another button to the menu until I totally delete the addin. Anyone know how I fix this?</p> <p>I would for example wrap the Command.AddControl() and later stuff in an if that only executes if the button doesn't already exist, but I can't seem to find a way to check this in the API?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload