Posted my piece of code to embed the IE WebBrowser control in .NET without wrapping DLL's [.NET] as a GDN User Sample In general it is a rework of the code posted here, but with some extensions I needed and without saving static html to temporary file to navigate to later. The crux of matter is how to define the correct Interop for IHTMLDocument2.Write().
Here is my working solution:
using System;
using System.Runtime.InteropServices;
namespace System.Windows.Forms.Html {
[InterfaceType(ComInterfaceType.InterfaceIsDual), ComVisible(true), Guid(@"332C4425-26CB-11D0-B483-00C04FD90119")]
interface IHTMLDocument2 {
...
///
/// Write complete html doc content including markup.
///
/// object[] containing the string(s)
///
///
/// IHTMLDocument2 document = control.GetDocument();
/// if (document != null) {
/// document.Open("", null, null, null);
/// object[] a = new object[]{"Hello world"};
/// document.Write(a);
/// document.Close();
/// }
///
///
void Write(
[In, MarshalAs(UnmanagedType.SafeArray)] object[] psarray);
...
}
}
May be there is an Interop Guy that is able to solve it in a more elegant way? Currently IJW. This functionality is covered by the control itself. Usage of that feature of IE Control looks like this:
htmlControl.Html = myHtmlString;
htmlControl.Navigate(null);
With this approach you will also get the NavigateXYZ() events to listen for further usage.