MFCIE Sample: Demonstrates the MFC CHtmlView and CReBar Classes

The MFCIE sample uses MFC's CHtmlView and CReBar classes to implement a subset of the functionality provided by Microsoft Internet Explorer.

The MFCIE sample provides a view very much like Microsoft Internet Explorer. You can browse to any location on the Web, enter data in forms, print Web pages, download files, or open files on your local hard drive. New addresses can be entered manually in the Address bar of the CReBar control, or hypertext links can be clicked on in the main view.

The sample demonstrates the ease in which a Web browsing capability can be inserted into any application. Most of the functionality of CHtmlView is trivial to implement (for example, GoHome or GoBack), although some of the less obvious features such as printing and font sizing have been implemented for your convenience. The MFCIE sample also demonstrates the proper method of retrieving and reading the Favorites selections and displays them in their own menu.

One thing to note is that the Web browser control used by CHtmlView does its own printing internally, so MFC's printing and Print Preview methods are bypassed entirely.

Security noteSecurity Note

This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.

To get samples and instructions for installing them:

To access samples from Visual Studio

  • On the Help menu, click Samples.

    By default, these samples are installed in drive:\Program Files\Microsoft Visual Studio 10.0\Samples\.

  • For the most recent version of this sample and a list of other samples, see Visual Studio Samples on the MSDN Web site.

Building and Running the Sample

To build and run the MFCIE sample

  1. Open the solution mfcie.sln.

  2. On the Build menu, click Build.

  3. Run the MFCIE application.

MFCIE assumes that you are already connected to the Internet. When it first starts, it will open your home page and you can browse from there just as you would with Microsoft Internet Explorer, either by using the Address bar, the Favorites menu, or by following links on the current page.

Keywords

This sample demonstrates the following keywords:

CToolBarCtrl::SetButtonWidth; CToolBarCtrl::SetHotImageList; CToolBarCtrl::SetImageList; CReToolBar::SetButtons; CReToolBar::SetButtonInfo; CReToolBar::SetButtonText; CReBar::AddBar; CHtmlView::Navigate2; CAnimateCtrl::Play; CAnimateCtrl::Stop; CAnimateCtrl::Seek; CComboBoxEx::InsertItem; CHtmlView::GoHome; CHtmlView::GoBack; CHtmlView::GoForward; CHtmlView::GoSearch; CHtmlView::Stop; CHtmlView::Refresh; CHtmlView::ExecWB

Note

Some samples, such as this one, have not been modified to reflect the changes in the Visual C++ wizards, libraries, and compiler, but still demonstrate how to complete your desired task.

See Also

Other Resources

MFC Samples