Use the following code to create a frame page, and then name the page framesetChild.htm:
<HTML>
<body>
This is a frame<br>
</body>
</HTML>
4.
Copy framesetChild.htm to the Web server.
5.
Create a default Microsoft Foundation Classes (MFC) dialog-based application.
6.
Right-click the dialog, and then click Insert ActiveX Control. Click Microsoft Web Browser Control.
7.
To add a control data member for the WebBrowser control, follow these steps:
a.
Open the Class Wizard, and then click the Member Variables tab.
b.
Make sure that the dialog class is selected in the Class name list.
c.
Click IDC_EXPLORER1 (which is the default ID of the WebBrowser control), and then click Add Variable.
d.
You receive a message that states that the control has not been inserted into the project. Click OK to add the control to the project. Click OK again to accept the defaults for the CWebBrowser2 class in the Confirm Class dialog box.
e.
Name your member variable m_webBrowser, and then click OK.
f.
Close the Class Wizard.
8.
To add the BeforeNavigate2 event handler, follow these steps:
a.
Open the Class Wizard, and then click the Message Maps tab.
b.
Make sure that the dialog class is selected in the Class name list.
c.
Click IDC_EXPLORER1 in the Object IDs list, and then click BeforeNavigate2 in the Messages list.
d.
Click Add Function to add the handler.
9.
Add the following code:
void CMFCReproDlg::OnBeforeNavigate2Explorer1(LPDISPATCH pDisp, VARIANT FAR* URL, VARIANT FAR* Flags, VARIANT FAR* TargetFrameName, VARIANT FAR* PostData, VARIANT FAR* Headers, BOOL FAR* Cancel)
{
static int nCount = 0;
nCount++;
if (nCount == 2) // this should be the navigate for the first frame in frameset
{
IWebBrowser* pWB = NULL;
HRESULT hr = pDisp->QueryInterface(IID_IWebBrowser, (void**)&pWB);
COleVariant ve((long)0);
pWB->Navigate(::SysAllocString(L"http://myserver/mydirectory/framesetChild.htm"), &ve, &ve, &ve, &ve);
*Cancel = VARIANT_TRUE;
}
}
10.
Add the following code to navigate to the frame page in the end of the OnInitDialog function.
To remove the borders, use one of following methods:
•
Post a user-defined message, and then perform the navigation in the user-defined message handler.
•
Follow the steps in Microsoft Knowledge Base article Q196835 to provide the custom control site in which you can add the IDocHostUIHandler interface. For additional information, click the article number below to view the article in the Microsoft Knowledge Base:
196835 (http://support.microsoft.com/kb/196835/EN-US/) HOWTO: Override the MFC Default Control Containment
After you implement all the functions, you must add DOCHOSTUIFLAG_NO3DBORDER to the DOCHOSTUIINFO stucture in the dwFlags field for the GetHostInfo method. It is beyond the scope of this article to provide the steps to implement IDocHostUIHandler.
NOTE: The border problem does not appear in an Active Template Library (ATL) container because the ATL class, CAxHostWindow, already implements the IDocHostUIHandler interface. By default, CAxHostWindow enables this flag.