Another example of using the Web Browser control


Hello from Greece.

My is showing an easy way to create a web browser. It uses Microsoft's ActiveX control for that purpose. There is already an example in the site, but i think mine is easier. That's because i use the Wizard to create the CWebBrowser class. As you see all we need to do is:

0. Add the Web Browser ActiveX control to the project. The AppWizard creates the CWebBrowser class for us.

1. We must create an instance of a CWebBrowser when OnCreate() Event occurs in our View class.

2. Use the OnSize() Event to size our control so that it covers the whole application's window.

3. Add some navigation buttons to the toolbar, with the appropriate handlers.

The job is very easy done because the AppWizard is creating the CWebBrowser class for us.

ATTENTION: The example code loads the a.htm, which must be at the same folder as the program.

The example code cannot be executed from the VC environment because it receives a wrong directory when, it calls the GetCurrentDir(), inside OnCreate() function and it cannot load the a.htm page.

Bye from Greece - Panagiotis.

Download Sample (59 kb)

Article added on June 21 1998


  • New one

    Posted by snareenactina on 12/10/2012 09:00pm

    What would you like to search for? misinterpret We need to educate America. apostolic cereno appignanesi playwriting beveragei

  • good

    Posted by chenghaiquan on 03/30/2009 10:50pm

    That's just what I needed. But it's a little simple!

  • Load HTML from Resources

    Posted by Legacy on 11/11/2003 12:00am

    Originally posted by: Nikitin_aka_KRoL

    How i can load html pages from resources?
    Using CWebBrowser;

  • Modify HTML data itself?

    Posted by Legacy on 08/21/2002 12:00am

    Originally posted by: Todd Rhodes

    I enjoyed learning from this; Thanks. If one wanted to make systematic translations to any browsed HTML files (i.e. colors, fonts, etc.) in real time prior to displaying them, what would be the easiest way to incorporate this? Is there an HTML class that has this built in, or would I have to build some sort of filter/mangler to operate on the HTML prior to displaying it?

  • IP address option

    Posted by Legacy on 02/06/2002 12:00am

    Originally posted by: alan

    I was wanting to stick an IPAddress control on the url dialog and insert an IP instead of a URL.

    Not sure how to do this as Navigate() only takes URL.

    And CIPAddressCtrl::GetAddress() returns a dword.

    any ideas?

  • Copy&Paste problem

    Posted by Legacy on 07/30/2001 12:00am

    Originally posted by: Uwe

    Hi the Example is a great work. But copy & paste doesn't works. Ctrl-C / Ctrl-V and the the Exec()-Method whit the OLECMDID_COPY Prop doesn't works.

    Any Idea ?



  • Need the Guru's comment!

    Posted by Legacy on 06/13/2001 12:00am

    Originally posted by: Yasuhiko Yoshimura

    This article is very great and useful.

    But I would like to get a working knowledge of IE5.5 hosting method for my active-x control.
    My active-x control is a DLL that manages document files ,prints them and previews them.
    I would plan to make IE5.5 control my active-x control like the Acrobat Reader4.0 that does show PDF documents delivered from any web site.

    I hope good ideas.

    Yasuhiko Yoshimura

  • How to intercept the contents of Homepage before showing in the IE browser without proxy?

    Posted by Legacy on 02/20/2001 12:00am

    Originally posted by: Yung-Ming Kuo

    Dear friends:

    I want to intercept and get the contents(including text and image) of homepage from Web server ,before it shows the IE browser(version 5.0).But it is not through proxy.

    And i have ability to prevent HTML document from showing the browser.

    Could you offer some suggestion or source code sample to solve my question?

    Thank you ^_^

    by Kuo

  • Very good work,

    Posted by Legacy on 11/13/2000 12:00am

    Originally posted by: ArunJose

    very nice work I was able to do the same with a dialog too.Thank u.

  • Works only on the computer on which this code is compiled ?

    Posted by Legacy on 09/12/2000 12:00am

    Originally posted by: Christophe Guibert

    I've compiled/linked this code in Windows 98 and it works fine. Thanks.

    But when I copy the EXE on another PC (with the same operating system and Visual C++ installation) :
    the program crashes on this new PC while initializing OLE.

    I've tried with various configurations (WinNT 4 and tried IE3 and IE4 CLSIDs) without success.

    Program would work only when compiled on the final target machine...

    Could anyone give help or advices on that subject, seemingly related with ActiveX ?



  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: May 6, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT While you likely have very good reasons for remaining on WinXP after end of support -- an estimated 20-30% of worldwide devices still are -- the bottom line is your security risk is now significant. In the absence of security patches, attackers will certainly turn their attention to this new opportunity. Join Lumension Vice President Paul Zimski in this one-hour webcast to discuss risk and, more importantly, 5 pragmatic risk mitigation techniques …

  • A help desk is critical to the operations of an IT services business. As a centralized intake location for technical issues, it allows for a responsive and timely solution to get clients and their staff back to business as usual. In addition to handling immediate IT issues, a help desk performs several proactive tasks to ensure clients' IT systems remain operational and downtime is minimized. Thus, utilizing a help desk and following best practices can improve the productivity, efficiency and satisfaction of …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds