Introduction WebBrowserControl for the C# .NET
This article presents an implementation of a web
browser control for the C# .NET. It's more of a reference for what it
does than how it's done.
This is not the result of my work but a collection
of all the help I got along the way.
Background of WebBrowserControl in C#
The need for this control came from a project I'm
working in. It's a smart client Windows application that host application in web
browsers and interacts with the pages.
What WebBrowserControl do?
This control is, mainly, an interface to the following
||This interface enables applications to implement an instance of
the WebBrowser control (Microsoft ActiveX control) or control an
instance of the InternetExplorer application (OLE Automation). Note
that not all of the methods listed below are supported by the
||Main web browser operation.
||This interface designates an event sink interface that an
application must implement in order to receive event notifications
from a WebBrowser control or from the Microsoft Internet Explorer
application. Note that not all of the events listed below are
supported by the WebBrowser control.
||Handling web browser events.
||This custom interface enables an application hosting the
WebBrowser Control or automating Microsoft Internet Explorer to
replace the menus, toolbars, and context menus used by MSHTML.
||Showing the context menu, translating keys and URLs.
||A host can supply mechanisms that will show message boxes and
Help by implementing the IDocHostShowUI interface.
||Showing message boxes (alert
confirm) and help.
||The IOleCommandTarget interface enables objects and their
containers to dispatch commands to each other. For example, an
object's toolbars may contain buttons for commands such as Print,
Print Preview, Save, New, and Zoom.
||Handling script errors.
Using the code
The MSHTML primary interop assembly (installed with
.NET Framework SDK Version 1.1 - usually %ProgramFiles%Microsoft.NETPrimary
Interop Assemblies) is needed to interop with HTML stuff.
Other than that, just add the control to your form
or user control.
Along the way, I lost the ability to use the