"Extending the .NET 2.0 WebBrowser control"
The Code Project - Extended .NET 2.0 WebBrowser Control
"
.NET 2.0 has a new WebBrowser
control in the System.Windows.Forms
namespace. This control itself is very useful, but doesn’t supply some events that might be needed in certain situations. This article explains how to extend the WebBrowser
control and add functionality for things like pop-up blocking, script error handling, and handling new windows in a tabbed browser environment.
For extending the WebBrowser
control, some features are not documented in the Help files of the .NET Framework. Not letting us be stopped by the "This method supports the .NET Framework infrastructure and is not intended to be used directly from your code." message, it is possible to create an object that implements IWebBrowser2
and use all the functionality of the underlying browser. Besides this, DWebBrowserEvents2
can be implemented for adding events to the control.
This article assumes that you have already some knowledge of the browser interfaces IWebBrowser2
and DWebBrowserEvents2
. Some knowledge about COM Interop and interfaces is also required.
2: The goals, challenges, and solutions
The goals of this component are:
- Handling script errors in a neat way
- Blocking unwanted pop-ups
- Enabling functionality for tabbed browsing or MDI browsing
- Making sure that a window is closed when it is closed by script
..."
Very Nice.
On a background thread I’ve been looking for an easy way to build a tabbed browser in .Net (as a host to a specific URL space, to build something like my Pandora Player for it...). I’ve not been able to hork one out with the new WebBrowser control, due to lack of the specific events I wanted to capture. And since it wasn’t easy, I paused the thread.
Well dugh, I should have known to not be lazy and just use IWebBrowser2 & DWebBrowserEvents2. And I’m already using that interface in a VB6 app... Double dugh.
Technorati Tags: Visual Studio 2005, IWebBrowser2, DWebBrowserEvents2, WebBrowser Control, CodeProject
No comments:
Post a Comment