Table of Contents
Using WebView Directly

In additional to using the corresponding WebControl wrapper class in a Windows Forms or WPF project, you can always use the WebView class directly.

In order to use WebControl directly, first you must have a window handle. The window handle identifies the window that will host the WebView. The following steps give an example of how to use WebView class this way. Note that while this sample is a Windows Form project, you can use WebView in any type of projects as long as you can supply the window handle needed by the WebView class.

  1. Create a new Windows Forms project;
  2. Add reference to EO.WebBrowser.dll. Note that you do not need to reference EO.WebBrowser.Wpf.dll;
  3. Open Form "Form1" in design view;
  4. Drag a PictureBox control onto the form;
  5. From solution explorer, right click "Form1.cs" if you use C#, or "Form1.vb" if you use VB, then click "View Code" from the context menu;
  6. Add the following code to class Form1 to declare a WebView variable:

    //Declare a new WebView object
    private EO.WebBrowser.WebView m_WebView = new EO.WebBrowser.WebView();
  7. Handle the Form's Load event and add the following code to initialize the WebView:

    private void Form1_Load(object sender, EventArgs e)
    {
        //Initialize the WebView using the PictureBox's window handle
        m_WebView.Create(pictureBox1.Handle);
        
        //Load Google's home page into the WebView
        m_WebView.Url = "www.google.com";
    }

Run the page and you should see Google home page is loaded. As demonstrated by the above code, the key is to supply a window handle to the WebView's Create method to initialize the WebView.