Click here to Skip to main content
6,822,613 members and growing! (15,409 online)
Email Password   helpLost your password?
Desktop Development » Miscellaneous » General     Intermediate

Browsers Wrapper ( Mozilla IE )

By zebulon75018

Describe a wrapper to render html page with mozilla or IE
C#2.0, Windows, .NET2.0VS.NET2003, Dev
Posted:2 Sep 2007
Views:18,692
Bookmarked:25 times
Unedited contribution
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
6 votes for this article.
Popularity: 2.54 Rating: 3.26 out of 5
1 vote, 16.7%
1
1 vote, 16.7%
2

3
2 votes, 33.3%
4
2 votes, 33.3%
5
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

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

Screenshot - IMG82.jpg

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;
IEBrowser.DocumentCompleted;

And the prototype of the Event too:

private void webBrowser_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
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

About the Author

zebulon75018


Member

Occupation: Software Developer (Senior)
Company: http://www.cmb-soft.com/
Location: France France

Other popular Miscellaneous articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 16 of 16 (Total in Forum: 16) (Refresh)FirstPrevNext
Generalsample doesn't seem to work in VS2008. PinmemberJohannNutter13:12 5 Aug '09  
GeneralException has been thrown by the target of an invocation. Pinmemberkillem6919:00 28 Mar '09  
GeneralRe: Exception has been thrown by the target of an invocation. PinmemberJohannNutter11:56 5 Aug '09  
GeneralUnable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported. PinmemberCalinaB12:14 22 Oct '08  
GeneralRe: Unable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported. Pinmemberzebulon7501811:40 15 Nov '08  
GeneralRe: Unable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported. PinmemberDaaron15:27 2 Dec '08  
GeneralRe: Unable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported. Pinmembertenzthomas21:54 19 Mar '09  
GeneralRe: Unable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported. PinmemberDaaron5:17 20 Mar '09  
GeneralRe: Unable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported. Pinmemberrbunn8381515:51 23 Mar '09  
QuestionRe: Unable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported. PinmemberKnud Andersen12:30 25 Mar '09  
AnswerRe: Unable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported. PinmemberDaaron12:34 25 Mar '09  
AnswerRe: Unable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported. PinmemberKnud Andersen12:51 25 Mar '09  
RantGrammar Check, please! PinmemberAlpha Nerd7:33 31 May '08  
GeneralJust what I was looking for Pinmembermerlin9814:43 4 Sep '07  
GeneralRe: Just what I was looking for Pinmemberzebulon750186:41 4 Sep '07  
GeneralRe: Just what I was looking for PinmemberVany3145:27 3 Oct '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

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

PermaLink | Privacy | Terms of Use
Last Updated: 2 Sep 2007
Editor:
Copyright 2007 by zebulon75018
Everything else Copyright © CodeProject, 1999-2010
Web22 | Advertise on the Code Project