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


  • How to implement search functionality in given example.

    Posted by Uday on 03/19/2014 10:26pm

    I am Looking for search functionality in browser control, when i type a keyword and click on search it should highlight the matching words in browser displayed content.

  • 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.

  • Loading, Please Wait ...

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

Top White Papers and Webcasts

  • Wednesday, September 24, 2014 8:00 AM - 9:00 AM PDT According to a recent Forrester Research report, many companies are choosing low-code platforms over traditional programming platforms, due to the speed with which low-code apps can be assembled and tested. With customer-facing applications on the rise, traditional programming platforms simply can't keep up with the "short schedules and rapid change cycles" required to develop these applications. Check out this upcoming webinar and join Clay Richardson from …

  • As mobile devices have pushed their way into the enterprise, they have brought cloud apps along with them. This app explosion means account passwords are multiplying, which exposes corporate data and leads to help desk calls from frustrated users. This paper will discover how IT can improve user productivity, gain visibility and control over SaaS and mobile apps, and stop password sprawl. Download this white paper to learn: How you can leverage your existing AD to manage app access. Key capabilities to …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds