Nowadays, writing a completely custom browser is not a difficult task—provided you can rely on the WebBrowser control that's available starting with Microsoft?Internet Explorer 3.0. The browser helper objects (BHO) introduced with Internet Explorer 4.0 gave you an opportunity to add even complex new functionality to the original browser. A couple of working examples of BHOs can be found in Scott Roberts' article in the May 1998 issue of MIND and in the January/February 1999 issue of MSDN?News.
Scott Roberts, "Controlling Internet Explorer 4.0 with Browser Helper Objects", MIND, 1998年5月期
Dino Esposito, "Browser Helper Objects: The Browser the Way You Want It", MSDN News, 1999年1/2月期
==============
There is just one aspect missing from all these pre-Internet Explorer 5.0 programming goodies: you couldn't associate new functionality with the browser's user interface. You had no way to add new toolbar buttons or to customize any of the menus. Thankfully, this problem has been solved with Internet Explorer 5.0.
Let's look at the new ways you can interface with the Internet Explorer UI, the points at which you're allowed to intervene, and what you can actually obtain through code. I'll briefly review the highlights of BHOs, focusing on scripting-related aspects of Internet Explorer 5.0 customization and registry changes. Windows Script Host (WSH) will be my development environment of choice here.
Figure 1 summarizes the aspects of Internet Explorer 5.0 that can be considered customizable. In particular, you can add new toolbar buttons and menu items. For each, you specify the text and icons to add to the particular object, as well as the code that you should run when the user selects the new entry. The browser has a number of context menus that appear when you right-click an image, a document, a table, an ActiveX?control, selected text, and other items. You can add new items to any of the context menus and have full control over the whole process that displays the menu. In other words, you can detect when the context menu is about to be shown and add your changes on the fly.
Internet Explorer 5.0 comes with a number of related applications that let you work outside the Web, such as email or news readers, HTML editors, and so on. You can modify the list of available applications to fit your needs. The search bar can be enhanced and you can even use your own search panel.
Technologies like Dynamic HTML (DHTML), behaviors, and XML provide excellent tools for customizing and extending browser features. You can create a browser implementing the IDocHostUIHandler interface, and expose a completely custom object model through that interface's External property (see "Take Total Control of Internet Explorer with Advanced Hosting Interfaces," by Scott Roberts in the October 1998 issue of MIND). You can use behaviors to customize the way a certain HTML tag reacts to user and browser solicitations by extending it with new methods, properties, and events.
Scott Roberts, "Take Total Control of Internet Explorer with Advanced Hosting Interfaces", MIND, 1998年10月期
==============
Customization Techniques
Customization of the Internet Explorer 5.0 user interface involves four elements: COM components, HTML, script files, and the registry. By writing a special COM component or script file and entering some keys and values to the registry, you can personalize the Internet Explorer interface. As I mentioned earlier, I won't discuss the COM stuff in depth here, but I will give you an overview of the COM component you can write to interact with Internet Explorer 5.0.
There are basically four types of Internet Explorer-specific COM objects: BHOs, BHOs with custom commands, command-only objects, and the Explorer deskband.
A BHO is a simple COM server that is only required to implement the IObjectWithSite interface. You can create a BHO with ATL by choosing the Internet Explorer object template from the ATL objects gallery. BHOs are also supported by Windows Explorer (if you're running shell version 4.71 or greater) and Internet Explorer 4.0. BHOs don't necessarily link with the UI; they are just actions you take when starting the browser. BHOs are passed a pointer to the browser's IUnknown interface.
==============
翻译讲解:一个BHO是一个简单的COM server,只需实现IObjectWithSite接口即可。可以用ATL创建一个BHO,从ATL objects gallery中选择Internet Explorer object template。Windows Explorer和IE4.0也支持BHOs。BHOs并不和UI相连,它只是在浏览器启动时起作用。BHOs会接收到一个指向浏览器IUnknown接口的指针。
==============
You can add new commands to the browser by writing BHOs, or even simpler COM objects, that implement IOleCommandTarget. With this interface, Internet Explorer 5.0 knows how to ask your component to execute a function. Such a component needs to be associated with a menu item or a toolbar button. The difference between a BHO and a COM server implementing IOleCommandTarget is that a BHO can easily access (via the received IUnknown pointer) any object model exposed by the document being viewed.