Browser Application

We can use the MFC AppWizard to create an application that displays any Web content that was specified.

Steps in building Web browser application:

Create a new project of type MFC AppWizard (exe) using the DevStudio Appwizard. Name it Browser. and allow all default setting by clicking next. In Step 6 of the wizard, use the Base class drop-down list to select 'CHtmlView'. 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 CBrowserView::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("http://www.microsoft.com/visualc/"),NULL,NULL);
}

Rebar's are added to the Mainframe window in OnCreate( ) handler. for knowing how to add rebar's to the window refer to 'ToolBars' section in this website. Handlers are added to all the buttons present on the rebar and CHtmlView members GoBack( ), GoForward( ), Stop( ), Refresh( ), GoHome( ), GoSearch( ) for the respective handlers.

No comments: