Click here to Skip to main content
Click here to Skip to main content

Browsers Wrapper ( Mozilla IE )

By , 2 Sep 2007
 
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;<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

About the Author

zebulon75018
Software Developer (Senior) http://www.cmb-soft.com/
France France
Member
No Biography provided

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralMy vote of 5membermanoj kumar choubey26 Feb '12 - 21:11 
Nice
GeneralPost data in mozilla AxMozillaBrowsermemberasmanmmsj15 Oct '10 - 15:25 
hi
how can i post data to a web site from AxMozillaBrowser
?
sample
http://example.com
postdata ="email:email@mail.com&pass=123"
 
AxMozillaBrowser1.Navigate("http://example.com") normal mode
 
for post data ?
Generalsample doesn't seem to work in VS2008.memberJohannNutter5 Aug '09 - 12:12 
Tried sample, got 1 syntax error after conversion, probably my fix was wrong, but it didn't show anything under either Mozilla or ie.
GeneralException has been thrown by the target of an invocation.memberkillem6928 Mar '09 - 18:00 
Hey, I have a serious problem when I'am trying open a site in mozilla web browser. In IE web Browser everything is OK. Please help me because I'amm using this component in my project which I must make in this week.
thanks for advice.
 

....
System.Reflection.TargetInvocationException was unhandled
  Message="Exception has been thrown by the target of an invocation."
  Source="mscorlib"
  StackTrace:
       at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
       at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
       at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
       at AxMOZILLACONTROLLib.AxMozillaBrowser.Navigate(String uRL)
       at WindowsApplication2.WrapperWebBrowser.Navigate(String url) in G:\MASTER DESKTOP\Desktop\Licencjat\Projects\WindowsApplication2\WindowsApplication2\WrapperWebBrowser.cs:line 67
       at WindowsApplication2.Form1.navigateToolStripMenuItem_Click(Object sender, EventArgs e) in G:\MASTER DESKTOP\Desktop\Licencjat\Projects\WindowsApplication2\WindowsApplication2\Form1.cs:line 44
       at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
       at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e)
       at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
       at System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
       at System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
       at System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
       at System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
       at System.Windows.Forms.Control.WndProc(Message& m)
       at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
       at System.Windows.Forms.ToolStrip.WndProc(Message& m)
       at System.Windows.Forms.MenuStrip.WndProc(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
       at System.Windows.Forms.Application.Run(Form mainForm)
       at WindowsApplication2.Program.Main() in G:\MASTER DESKTOP\Desktop\Licencjat\Projects\WindowsApplication2\WindowsApplication2\Program.cs:line 17
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: System.Runtime.InteropServices.COMException
       Message="Error HRESULT E_FAIL has been returned from a call to a COM component."
       Source="Interop.MOZILLACONTROLLib"
       ErrorCode=-2147467259
       StackTrace:
            at MOZILLACONTROLLib.IWebBrowser2.Navigate(String URL, Object& Flags, Object& TargetFrameName, Object& PostData, Object& Headers)
       InnerException: 
 

GeneralRe: Exception has been thrown by the target of an invocation.memberJohannNutter5 Aug '09 - 10:56 
Ever get an answer to this? I'm trying to use the Mozilla browser control in VS 2008 VB.NET, but when I say webbrowser1.navigate("http://www.yahoo.com"), it says "Exception has been thrown by the target of an invocation."
GeneralUnable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported.memberCalinaB22 Oct '08 - 11:14 
I'm running your project on Visual Studio 2008, Vista. I also have Firefox 3.0 installed.
I get this error:
{"Unable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported."}
on the line of code:
((System.ComponentModel.ISupportInitialize)(this.axMozillaBrowser1)).EndInit();
 
I've tried to build my own project, and even if I add reference to MozillaBrowser Class, the control does not show in my Toolbox.
 
Can you please help?
 
thank you,
 
Calina B

GeneralRe: Unable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported.memberzebulon7501815 Nov '08 - 10:40 
Sorry, I don't have Vista...
Check the site of the ActiveX Mozilla for more information.
GeneralRe: Unable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported.memberDaaron2 Dec '08 - 14:27 
I couldn't find a way around it with Vista, had to move back to XP.
Works there without a problem.
 
Cheers,
Daaron

GeneralRe: Unable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported.membertenzthomas19 Mar '09 - 20:54 
yes i know that its working fine with xp but , can anyone guide me in the scenario of vista, where my application is continously throwing exception.
GeneralRe: Unable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported.memberDaaron20 Mar '09 - 4:17 
I am not sure how much guidance is necessary, but I'm willing to help. I am using Vista Business with VS08.
 
Cheers,
Daaron

GeneralRe: Unable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported.memberrbunn8381523 Mar '09 - 14:51 
I think your problem may relate to this KB article. If you solve the problem please let me know.
 
http://support.microsoft.com/kb/927377
 
Bob
QuestionRe: Unable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported.memberKnud Andersen25 Mar '09 - 11:30 
Daaron,
This is not related to this subject, but I have a question for you:
What happened to the WatiNRecorder project? Am I correct in assuming, it is more or less dormant for the past 2 years? has someone else taken over ? (the current versions does not run with .Net 2.x or 3.x, so I thought I would just find the source and recompile ... not that easy - the source I did find does not seem complete (after conversion to VS2008) ... is there any chance you can update me (us) on the status - e.g. update the watintestrecord.sourceforge.net ... or was that not yours ... thanks in advance (and sorry if this was not the right place)
 
Knud
AnswerRe: Unable to get the window handle for the 'AxMozillaBrowser' control. Windowless ActiveX controls are not supported.memberDaaron25 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.memberKnud Andersen25 Mar '09 - 11:51 
Send me the installer if you want a beta tester ...
or the source code if you want help (Not that I am good a C#, but definetely willing to learn) ...
Looking forward to the new version ...
 
/knud
RantGrammar Check, please!memberAlpha Nerd31 May '08 - 6:33 
This article is great Smile | :) , but you need to check your grammar. And maybe spelling. Frown | :(
 
I'd been called 'ugly', 'pug ugly', 'fugly', 'pug fugly' but never 'ugly ugly'. - Moe Szyslak

GeneralRe: Grammar Check, please!memberzebulon7501810 Dec '10 - 17:33 
Sorry I 'm really busy....
GeneralJust what I was looking formembermerlin9814 Sep '07 - 3:43 
I've been looking for a good Mozilla control for a long time. Thanks for sharing!
 


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
I get my developer tools from Merlin A.I. Soft

Rhabot - World of Warcraft Bot

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

GeneralRe: Just what I was looking formemberzebulon750184 Sep '07 - 5:41 
Thank's for the appreciation.
I thinking about make a user control where you can choose between IE , and Mozilla.
But It'll more complicated because I have to map the API of IE And the API of Mozilla.
It can be a good evolution.
GeneralRe: Just what I was looking formemberVany3143 Oct '08 - 4:27 
thumbs up!
that's something I thought about, but I see it's nearly done...Wink | ;-)

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

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 2 Sep 2007
Article Copyright 2007 by zebulon75018
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid