Magazine |
| | Community |
| | Workshop |
| | Tools & Samples |
| | Training |
| | Site Info |
Samples
|
Reusing Browser TechnologyDriller (MFC) Sample |
||||
Download sample | ||||
Description
Driller is an MFC based control host, that hosts the WebBrowser Control. Built Using VC++5.0.
More DetailsThe functionality of drilling into the document hosted and listing the tags found in the listbox is discussed in the readme file for Driller, which additionally covers the DrillVB sample.
The Driller sampler adds additional functionality by providing extra control through the implementation of the IDocHostUIHandler interface. This interface is documented in the SDK; this sample shows how this interface can be used to control the context menus and extend the Dynamic HTML Object Model.
Browser/Platform CompatibilityThis sample is supported in Internet Explorer 4 and Internet Explorer 5.
NOTE: Due to an incompatibility between VC 6.0 ATL and the NT 5.0 beta headers, you should not include the Internet Explorer 5.0 Beta headers and libraries nor the Windows NT 5.0 beta headers and libraries in your include or libpath.
For example, if you installed the SBN headers and libraries under root directory "C:\SBN" and you installed Visual C++ in the "C:\Program Files\Microsoft Visual Studio\VC98" directory, in Visual C++ your global directory options (Tools->Options->Directories tab) for your Include Files should resemble the following:
C:\Program Files\Microsoft Visual Studio\VC98\INCLUDE
C:\Program Files\Microsoft Visual Studio\VC98\MFC\INCLUDE
C:\Program Files\Microsoft Visual Studio\VC98\ATL\INCLUDE
This is different from any of the non-ATL samples in the Samples Gallery, all of which require the SBN path and the NT50 path to be added to the directory list.
Usage
The Context menus that appear as standard for a right mouse click are disabled within the Driller sample. This is achieved by returning S_OK from the ShowContextMenu method of the IDocHostUIHandler interface, indicating that the host has handled the call and the IE components need not perform the standard processing.
The Dynamic HTML Object Model is also extended in the Driller sample by providing an IDispatch interface to the getExternal method of the IDocHostUIhandler interface. This IDispatch is used whenever the script within the HTML document refers to window.external; whatever follows this will be handed to the GetIDsof Names member function of the IDispatch interface to be resolved. This can be seen by loading the extend.htm file supplied into Driller and pressing the Extend button.
To implement the IDocHostUIHandler, the client site needs to implement the interface. In MFC, the class COleControlSite encapsulates the client site. In this example we are subclassing MFC, a class CCustomControlSite, is derived from COleControlSite and CCustomControlSite implements IDocHostUIHandler. To hook in the CCustomControlSite, a class CCustomOccManager is derived from COccManager. Subclassing COccManager and COleControlSite in such a manner is implementation specific to MFC. So, if future versions of MFC change the implementation of COleControlSite or COccManager, this sample (and your code if you use this technique) might not work. We are looking at possible ways to have MFC expose the client site for customization. If in future MFC does expose the client site, then we will modify this sample to use that functionality.
If you are using this sample to design your code please be advised that you may have to change your code in the future.
It is possible that this sample will not compile because an include directory has not been identified. The program looks for the file called occimpl.h. Prepended to the header file is the directory where that file was located on the test machine. This may be different than most users. The solution is to delete the prepended directory and under project==> settings, go to the C/C++ tab, look under Preprocessor and then add the include directory to the additional include directories. An example of what that might look like is: c:\program files\devstudio\vc\mfc.