开发者

Open web browser window in VS 2010 via add-in code?

I'm porting a VS Add-in to VS 2010 from VS 2008 and need to be able to open the built-in web browser.

In VS 2008, it was possible to get a handle on the web browser window with code like this:

var win开发者_开发问答 = _applicationObject.Windows.Item(Constants.vsWindowKindWebBrowser);

However, the same code does not work in VS 2010 when an instance of the web browser has not already been opened. Instead it gives an ArgumentException on the Item index.


This appears to work:

_applicationObject.ItemOperations.Navigate("about:blank", vsNavigateOptions.vsNavigateOptionsDefault);

This code opens the specified file in the browse window whether it's already opened or not. And then it's possible to grab a reference to the window object and wire up events such as BeforeNavigate2.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜