Groups | Blog | Home
all groups > visual studio .net ide > march 2004 >

visual studio .net ide : Problem in Creating the Toolbars in Visual Studio IDE


Saradhi
3/8/2004 6:34:11 PM
I am trying to create my own toolbar and menu items inside my VS.NET =
AddIn as follows:

Office.CommandBars commandBars =3D applicationObject.CommandBars;=20

try

{

m_CmdBar =3D (Office.CommandBar)commandBars["Palantir Fellowship"];

string test =3D m_CmdBar.Name; //this will throw an ArgumentException if =
the bar doesn't exist

}

catch(Exception)

{

m_CmdBar =3D null;

}

if ( m_CmdBar =3D=3D null )

{

m_CmdBar =3D applicationObject.Commands.AddCommandBar("Palantir =
Fellowship", EnvDTE.vsCommandBarType.vsCommandBarTypeToolbar, null, 1) =
as Office.CommandBar;

}=20

m_CmdBar.Position =3D Office.MsoBarPosition.msoBarTop;

m_CmdBar.Visible =3D true;=20

// add a button on the toolbar for the apply changes

try

{

m_ApplyChangesBtn =3D m_CmdBar.Controls["Apply Changes to =
Fellowship..."] as Office.CommandBarButton;

}

catch{}

if ( m_ApplyChangesBtn =3D=3D null )

{

m_ApplyChangesBtn =3D AddButtonToToolbar(m_CmdBar, "Apply Changes to =
Fellowship...", "Apply Changes to Fellowship...", "OnApplyChangesClick", =
"ApplyChanges", true, true, true, false);

}


// Add a menu item to Build Menu to apply changes

Office.CommandBar cmdBar =3D commandBars["MenuBar"];

m_BuildMenu =3D =
cmdBar.FindControl(Office.MsoControlType.msoControlButtonPopup, =
cmdBar.Controls["Build"],=20

Missing.Value, Missing.Value, false) as Office.CommandBarPopup;

m_ApplyChangesMenuItem =3D AddButtonToMenu(m_BuildMenu, "ApplyChanges", =
"Apply Changes to Fellowship...", "OnApplyChangesClick", true, true, =
true, false);=20



Saradhi
3/11/2004 11:48:18 AM
After further study, I have commented the two lines which raises the =
EXception=20
m_CmdBar.Position =3D Office.MsoBarPosition.msoBarTop;
and=20
m_CmdBar.visible =3D true;

Now
another Exception is thrown at the line.=20
=20

1) Office.CommandBar cmdBar =3D commandBars["MenuBar"];

in the following code

Office.CommandBars commandBars =3D applicationObject.CommandBars;=20

// Add a menu item to Build Menu to apply changes

Office.CommandBar cmdBar =3D commandBars["MenuBar"];

m_BuildMenu =3D =
cmdBar.FindControl(Office.MsoControlType.msoControlButtonPopup, =
cmdBar.Controls["Build"],=20

Missing.Value, Missing.Value, false) as Office.CommandBarPopup;

m_ApplyChangesMenuItem =3D AddButtonToMenu(m_BuildMenu, =
"ApplyChanges", "Apply Changes to Fellowship...", "OnApplyChangesClick", =
true, true, true, false);=20



and I ahve noticed that my IDE has no Build Menu after the above code.

=20

2) Again, after commenting the two lines, my toolbar is getting =
created somewhere in the IDE as in the following figure, but whenever I =
clicked on my toolbar button, the tool bar disappears.=20









AddThis Social Bookmark Button