Click here to Skip to main content
15,881,172 members
Articles / Programming Languages / C#
Article

Browsers Wrapper ( Mozilla IE )

Rate me:
Please Sign up or sign in to vote.
3.35/5 (7 votes)
2 Sep 20072 min read 96.2K   3.6K   31   19
Describe a wrapper to render html page with mozilla or IE
Screenshot - IMG76.jpg

Introduction

If you want to embbeded a web browser in your application, with dotnet 2.0 there's a new control WebBrowser

( A good article about WebBrowser ) .it's the engine of Internet Explorer.

I discover recently there's an Mozilla ActiveX Plug-in, so I have tried to make a c# wrapper class to have the choose between Internet Explorer , and Mozilla to render the Html page.

This article will show about to use the Mozilla ActiveX, and how to have both IE , and Mozilla.

I don't go really inside the Mozilla Active X, may be for a update of this article.

I make a small test application, with the two html rendering objet,

I take two screenshots:

One with IE, and the second why Mozilla.

To make the different between the 2 browser , look the context menu.

Internet Explorer :

Screenshot - IMG77.jpg

Mozilla :

Screenshot - IMG78.jpg


Installing the Mozilla ActiveX

Install the Mozilla ActiveX Plug-in.
Click on the toolbox with the right button , choose Items.
You will find in Com object this line MozillaBrowser Class underlined red.
Screenshot - IMG79.jpg
Image 5

So when you have selected it , a new icon appear in the toolbox:

Screenshot - IMG82.jpg

Image 7

Using the code

The class WrapperWebBrowser.cs have

// The constructor 
 public WrapperWebBrowser(
 ref AxMOZILLACONTROLLib.AxMozillaBrowser moz,
 ref System.Windows.Forms.WebBrowser ie
 )


public enum EnumTypeBrowser { IE, MOZILLA }; 


// You can set , or get the TypeBrowser 
// Exemple TypeBrowser = EnumTypeBrowser.IE 

public EnumTypeBrowser TypeBrowser; 


// Set the delegate when the document complete downloaded 
public void SetDocumentCompleteEvent(DelegateDocumentComplete docCompleteEvent)

// Set the url of the browser web.
public void Navigate(string url)

If you want to use the WrapperWebBrowser.cs you have to make

a WebBrowser
and axMozillaBrowser

WrapperWebBrowser wrapperWebBrowser = null;

public Form1()
{
InitializeComponent();
wrapperWebBrowser = new WrapperWebBrowser(ref this.axMozillaBrowser1,ref this.webBrowser1);
wrapperWebBrowser.SetDocumentCompleteEvent(DocumentComplete);
}


private void DocumentComplete(string url)
{
this.Text = url;
}

If you change the property wraperWebBrowser.TypeBrowser then the window of the browser you choose will be visible and

the other browser window will be not visible of course.

Points of Interest

There's some difference between WebBrowser and AxMozillaBrowser, but they are quite similar .

There's Navigate in each, the name of the callback when the Document is complete change a little bit:

mozillaBrowser.DocumentComplete;<br />

IEBrowser.DocumentCompleted;

And the prototype of the Event too:

private void webBrowser_DocumentCompleted(object sender,
WebBrowserDocumentCompletedEventArgs e)<br />

private void axMozillaBrowser_DocumentComplete(object sender,
AxMOZILLACONTROLLib.DWebBrowserEvents2_DocumentCompleteEvent e)

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Software Developer (Senior) http://www.cmb-soft.com/
France France
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
GeneralMy vote of 5 Pin
Manoj Kumar Choubey26-Feb-12 21:11
professionalManoj Kumar Choubey26-Feb-12 21:11 
GeneralPost data in mozilla AxMozillaBrowser Pin
asmanmmsj15-Oct-10 15:25
asmanmmsj15-Oct-10 15:25 
Generalsample doesn't seem to work in VS2008. Pin
JohannNutter5-Aug-09 12:12
JohannNutter5-Aug-09 12:12 
GeneralException has been thrown by the target of an invocation. Pin
killem6928-Mar-09 18:00
killem6928-Mar-09 18:00 
GeneralRe: Exception has been thrown by the target of an invocation. Pin
JohannNutter5-Aug-09 10:56
JohannNutter5-Aug-09 10:56 
GeneralUnable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported. Pin
CalinaB22-Oct-08 11:14
CalinaB22-Oct-08 11:14 
GeneralRe: Unable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported. Pin
zebulon7501815-Nov-08 10:40
zebulon7501815-Nov-08 10:40 
GeneralRe: Unable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported. Pin
Daaron2-Dec-08 14:27
Daaron2-Dec-08 14:27 
GeneralRe: Unable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported. Pin
tenz200919-Mar-09 20:54
tenz200919-Mar-09 20:54 
GeneralRe: Unable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported. Pin
Daaron20-Mar-09 4:17
Daaron20-Mar-09 4:17 
GeneralRe: Unable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported. Pin
rbunn8381523-Mar-09 14:51
rbunn8381523-Mar-09 14:51 
QuestionRe: Unable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported. Pin
Knud Andersen25-Mar-09 11:30
Knud Andersen25-Mar-09 11:30 
AnswerRe: Unable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported. Pin
Daaron25-Mar-09 11:34
Daaron25-Mar-09 11:34 
I'm actually getting close to version 2 of the recorder. Just this morning I updated the WatiN library to 2.0, and I anticipate having a beta in a week or two. When I have a beta, I will definitely be updating the web page.

Cheers,
Daaron

AnswerRe: Unable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported. Pin
Knud Andersen25-Mar-09 11:51
Knud Andersen25-Mar-09 11:51 
RantGrammar Check, please! Pin
The Cake of Deceit31-May-08 6:33
The Cake of Deceit31-May-08 6:33 
GeneralRe: Grammar Check, please! Pin
zebulon7501810-Dec-10 17:33
zebulon7501810-Dec-10 17:33 
GeneralJust what I was looking for Pin
merlin9814-Sep-07 3:43
professionalmerlin9814-Sep-07 3:43 
GeneralRe: Just what I was looking for Pin
zebulon750184-Sep-07 5:41
zebulon750184-Sep-07 5:41 
GeneralRe: Just what I was looking for Pin
Vany3143-Oct-08 4:27
professionalVany3143-Oct-08 4:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.