Share via


Creating a Web browser-style Application

OverviewHow Do IDetails

You can use the MFC AppWizard to create an application that displays any Web content you specify.

To create a Web browser application

  1. Follow the steps to .

    Your application must be based on the MFC document/view architecture (default).

  2. In Step 6 of the wizard, use the Base class drop-down list to select CHtmlView.

  3. Click Finish.

The CHtmlView class acts as a wrapper for the Web browser control, which gives your application a view onto a Web, or HTML page. The wizard creates an override to the OnInitialUpdate function in the view class, providing a navigational link to the Microsoft Visual C++ Web site:

void CWebView::OnInitialUpdate()
{
   CHtmlView::OnInitialUpdate();

   // TODO: This code navigates to a popular spot on the web.
   //  change the code to go where you'd like.
   Navigate2(_T("https://msdn.microsoft.com/visualc/"),NULL,NULL);
}

You can replace this site with one of your own, or you can use the LoadFromResource function to open an HTML page that resides in the project's resource script as the default content for the view. For example:

void CWebView::OnInitialUpdate()
{
   CHtmlView::OnInitialUpdate();

   // TODO: This code navigates to a popular spot on the web.
   //  change the code to go where you'd like.
   LoadFromResource(IDR_HTML1);
}

What do you want to know more about?

What do you want to do?