开发者

Why does Visual Studio 2010 hide my add-in toolbar on launch?

开发者 https://www.devze.com 2023-01-02 17:13 出处:网络
I\'ve a VS add-in that creates a toolbar and displays it (based on previous visibility settings) when VS launches.

I've a VS add-in that creates a toolbar and displays it (based on previous visibility settings) when VS launches. The add-in works fine in VS 2005 and 2008 but in 2010, the toolbar is only visible while VS is loading.

Once VS has completed loading, the toolbar disappears开发者_Python百科.

I can replicate the sample problem with the Alpha Blend code sample: http://code.msdn.microsoft.com/AlphaBlendToolbar

To reproduce: Register the add-in and configure it to start when VS starts. Close VS and re-open it. The toolbar is visible for a few moments and it then disappears!!


As it turns out, the problem is with setting the visibility of the toolbar too early. When you delay setting the visibility until the toolbar is completely configured, then it works in VS 2010 - which is strange as the same code worked fine in VS 2003, VS 2005 and VS 2008!

Anyway, to keep the toolbar visible in the AlphaBlend code sample, comment out the toolbar configuration lines as below:

CommandBar toolbar = commandBars.Add("AlphaToolbar", MsoBarPosition.msoBarTop, System.Type.Missing, true);
//toolbar.Visible = true;
//toolbar.Enabled = true;

And reinstate them after the controls have been added to the toolbar:

commandOmega.AddControl(toolbar, 2);
toolbar.Visible = true;
toolbar.Enabled = true;

Thanks to NeelimaM for helping to spot this over on the MSDN Code Gallery site.

0

精彩评论

暂无评论...
验证码 换一张
取 消