CustWBC.exe sample shows how to control the WebBrowser control that is embedded in an ATL HTML control (247073)
The information in this article applies to:
- The Microsoft Active Template Library (ATL) 3.0, when used with:
- Microsoft Visual C++, 32-bit Enterprise Edition 6.0
- Microsoft Visual C++, 32-bit Professional Edition 6.0
- Microsoft Visual C++, 32-bit Learning Edition 6.0
This article was previously published under Q247073 SUMMARY CustWBC.exe is a sample that illustrates how you can
control the WebBrowser control that is embedded in an ATL HTML control. In
particular, the sample demonstrates three points: - How to provide a custom implementation of the IDocHostUIHandlerDispatch interface. The custom implementation disables the context menu of
the WebBrowser control.
- How to extend the functionality of the WebBrowser control
with additional methods accessible through window.external from within the
control's HTML. This feature is present in Wizard-generated code, but take
special actions to integrate this feature into your custom IDocHostUIHandlerDispatch.
- How to provide a sink for the WebBrowser control events.
The sink interface presented here reacts when the browser notifies your control
that the user requested to navigate in a new browser window (by shift+clicking
a link). Instead of opening a new window, use the window already open to go to
the requested URL.
MORE INFORMATIONThe
following file is available for download from the Microsoft Download
Center:
Release Date: May 17, 2000
For more information about how to download Microsoft Support files, click the following article number to view the article in the Microsoft Knowledge Base:
119591 How to obtain Microsoft support files from online services
Microsoft scanned this file for viruses. Microsoft used the most current virus-detection software that was available on the date that the file was posted. The file is stored on security-enhanced servers that help prevent any unauthorized changes to the file.
The implementation of the HTML control actually requires
four separate objects: the control itself, the object that implements the IDocHostUIHandlerDispatch interface, the object that implements the extender methods, and
the object that implements the sink. You need all four objects because all of
them need to implement IDispatch. The IDocHostUIHandlerDispatch implementation returns E_NOTIMPL for most of the methods except
the ShowContextMenu method. This method returns S_OK without displaying anything.
This convinces the WebBrowser control that it doesn't need to do anything about
the right button click. The sink only implements the Invoke method of IDispatch as follows:
STDMETHOD (Invoke) (DISPID dispidMember, REFIID riid, LCID lcid,
WORD wFlags, DISPPARAMS* pdispparams, VARIANT* pvarResult,
EXCEPINFO* pexcepinfo, UINT* puArgErr)
{
HRESULT hr = S_OK;
if (pdispparams)
{
switch (dispidMember)
{
// When a request comes in asking for a new window, go to the
// URL specified in the request, but within the old Web browser window.
case DISPID_NEWWINDOW:
// case DISPID_FRAMENEWWINDOW:
if (m_pBrowser)
{
VARIANT defArg;
defArg.vt = VT_ERROR; defArg.scode = DISP_E_PARAMNOTFOUND;
m_pBrowser->Navigate(pdispparams->rgvarg[5].bstrVal,
&defArg, &defArg, pdispparams->rgvarg[2].pvarVal, &defArg);
}
*(pdispparams->rgvarg[0].pboolVal) = VARIANT_TRUE;
hr = S_OK;
break;
default:
hr = DISP_E_PARAMNOTFOUND;
break;
}
}
else
hr = DISP_E_PARAMNOTFOUND;
return hr;
} Finally, the control's OnCreate method instantiates all these elements and sets everything
up. (c) Microsoft Corporation 1999, All Rights Reserved.
Contributions by Cosmin Radu, Microsoft Corporation. REFERENCESFor additional
information, click the article number below to view the article in the
Microsoft Knowledge Base: 202009 BUG: Error Accessing Window.external in ATL DHTML Control
Modification Type: | Major | Last Reviewed: | 6/7/2005 |
---|
Keywords: | kbhowto kbActivexEvents kbConnPts kbCtrl kbfile kbhtml kbinfo kbSample KbUIDesign KB247073 kbAudDeveloper |
---|
|