Hosting Mozilla/IE in one page of C++
Date: 5/8/2005
I don't think anyone has put is as succiently as this before. It's written with ATL and you'll need to link with comsupp.lib but other than that it's pretty self contained.

All you need to do is start using the IWebBrowser2 pointer 'Browser'.
06/08/2005 5:56am
Whew... I don't think you've every posted something I understand less. If you feel like explaining what it does, as it seems you're proud of it, I'd like some clarification.

I'm not familiar with the word "Hosting", in this context, but studying the next post makes it seem like you're embedding the browser rendering engines in another application. Is that right? Also, it took me a while to figure out what ATL is, as google doesn't turn up anything useful on it's own. So I realize that ATL is an activeX library, but what is that library useful for? Thanks for the clarification, if you feel like it.
06/08/2005 8:11am
RTE = a rich text editor built inside a browser.

Mozilla ActiveX = A compatible implementation with IE's API except using the mozilla gecko engine.

ActiveX Hosting = means that your application is a container for an ActiveX control. In my case I'm hosting the mozilla activex control which then runs the RTE webpage.

ATL = Active template library is a wrapper around the COM layer in windows, it makes writing COM code much easier. MFC is the other common COM library, but it has a lot of other things as well which most apps never use. ATL is a lightweight thing that adds very little bulk to your app. And it doesn't have any dependencies if you don't want them. Unlike MFC which has to pull in the entire MFC codepage (1mb or more).
06/08/2005 8:13am
I might add also that ATL makes hosting ActiveX controls really easy, hence the above code snippit being so small. To write an ActiveX control container in raw C++ is very difficult and takes a lot of code.
07/08/2005 1:27am
Thank you :)
05/10/2005 7:21am
this works?
don't you need to write something like
#import "PROGID:Mozilla.Browser.1" ...
05/10/2005 7:45am
Nope, this works without anything like that. The interfaces are defined in the Visual C++ headers.
02/12/2005 2:28pm
Sorry, but this is NO hosting of Mozilla!!! What you are hosting is the IE WebBrowser control... and with it, you navigate to Mozilla homepage!!

How naive could you be!! Seriously, youre entry start big laugh in our office!
:-D :-D
02/12/2005 8:39pm
donMiguel: You would need to have the mozilla activex control installed, otherwise windows will make an instance of IE. In fact windows might just revert to IE if there is any error. This code when run on my machine DOES use the mozilla control. You can see the "Ctrl" variable which is compile time switchable via a #if between the Mozilla control string and the IE control string.

Btw, installing Mozilla doesn't necessarily give you the activex control. I had to use a specific mozilla activex download to get it to work.
23/02/2006 1:04pm
sorry I am a newbee and I want to embed the Mozilla ActiveX Control without MFC and your code seems to be able to do that. But I don't know how to use it!

I have VC++ 6.0 any advice on how to use the code will be very much appreciated.

Thank You.
23/02/2006 9:30pm
me: It's pretty simple, paste the code into a new source file (.cpp), create a new win32 application project, add the source file, add the library 'comsupp.lib' to the link section and build! Thats it. It's so simple I didn't bother making a download for it.
24/02/2006 6:26am
Thank so very much for that just one more question..

how do i access other browser functions like refresh, stop, back etc?

I used

but that makes the app crash.

Thanks You.
24/02/2006 6:30am
me: Um, I don't know. You'll have to look at the API documentation for IWebBrowser2. This is just to get you over the hosting hurdle... not as a finished application worth anything. I really havn't done much more than whats above.
Email (optional): (Will be HTML encoded to evade harvesting)
Remember username and/or email in a cookie.
Notify me of new posts in this thread via email.