Basic Interface Usage (reprinted)Http://blog.csdn.net/jiangsheng/archive/2003/11/09/3791.aspx
Clsid_webbrowserIs the starting point of all things -- it isWebbrowser ActiveXControlCLSID.Internet Explorer 4.0In fact, it is just calledInternet ExplorerThe host of this control.Program.
Iwebbrowser2 InterfaceQuiltWebbrowser ControlAnd represents the main way to interact with the control. As a genetic InterfaceIwebbrowserThe New InterfaceGet_documentProvides a way to access the underlying DHTML document.
You pairWebbrowser ControlCurrently displayed inDHTML documentCurrentlyIhtmldocument2Interface implementation. It allows you to set and obtain document elements, set various event processing scripts, and obtain interfaces for window and framework display of documents.
(Note: in many cases, it is likely that you have to obtain a distribution interface for backward compatibility .),For exampleGethtmldocumentMethod, or encapsulate the DOM method of the class by adding the browser control to the project, and then query the ihtmldocument2 interface. Mfc7Source codeDirectly convert the delivery interface pointer to ihtmldocument2 pointer, which means that at least currently, the delivery interface pointer and ihtmldocument2 pointer point to the same object, but Microsoft does not guarantee that this will always happen, therefore, it is safer to call the iunknown QueryInterface method to obtain the ihtmldocument * pointer of the desired version. This method is also applicable to your own use of winapi.Clsid_webbrowserThe created browser window .)
Ihtmlwindow2Yes displayHtmlDocument window interface. This interface actually represents a framework set, and the current window may be part of it. Similar to HTML document objects, it also allows you to operate windows, set scripts for handling various events, and obtain an event object, representing the details of interaction between users and documents and windows.
IhtmleventobjIs an interface that represents an event object, including event information, such as the cursor position, the key pressed, and anyHtmlElement.
IhtmlelementIs an interface, representingHtmlElements in the document.HTML ElementIt is probably equivalent to an independent label in the document .. This method allows you to do something, such as setting scripts for processing various events and operating ElementInnerhtmlAndOuterhtmlAttribute to change the display HTML.
So far, all the above interfaces exist inInternet Explorer DHTML Object Model. However, to allow your application to process the events generated by these objects, you need to understand some distribution interfaces. The interfaces to be described in the next step are derived fromIdispatchAnd is an event processor that an application must implement. It is used to receive events from an object. To use these processor objects, You need to requestIconnectionpointcontainer Interface, Register at one of these locations. As long as you have a connection point container, you canEvent ProcessorEstablish a connection between them. When an event occurs, the object will send an event to the provided processor. You must understand at least three of the following distribution interfaces:
Diid_dwebbrowser event 2 InterfaceAllow you to monitorWebbrowser ControlEvents generated. A particularly important event isDispid_navigatecompleteTo notify its host file to be completelyWebbrowser ControlCreate. As long as this event is triggered,Iwebbrowser2: get_documentMethod returnsDHTML documentOfInterfacePointer.
With the diid_htmldocument event Interface, An application can receiveDHTML documentObject-triggered events, suchOnmouseover,Onmousemove, OrOnclick.
ThirdInterfaceYesDiid_htmlwindow event. ThisDiid_htmlwindow eventThe provided event isDHTML Object ModelIn. Examples of these events include:Onload,OnUnload,OnfocusAndOnblur.
Other two importantInterface icustomdocAndIdochostuihandlerAllow you to customizeInternet ExplorerUser Interface decoration and ExpansionDHTML Object Model.
the icustomdoc interface is implemented by HTML document objects, allows the webbrowser Control host to set its idochostuihandler interface. Generally, Internet Explorer calls the query Interface method to obtain the idochostuihandler interface. However, if the host does not support ioleclientsite interface or you want to save this pointer to avoid repeated calls QueryInterface , you can use icustomdoc to explicitly set the HTML Object idochostuihandler interface .
Idochostuihandler InterfaceOptionalWebbrowser Control. By implementing this interface, the host program can replaceInternet Explorer 4.0Used menu, toolbar, and context menu. WhenWebbrowserYou need to access the user interface (such as the window size), or when it needs to be parsedDHTMLWindow objectExternalAttribute,Webbrowser ControlQueries the Host Program'sIoleclientsite Interface(Unless it has been explicitly set ).
Control HostThe script engine can also be expanded by providing an external Automation Object that represents the Host Program.DHTML Object Model. The reference to this external object in the script is parsed by the script engine to start a pairWebbrowserHost applicationIdochostuihandlerInterface query. ThenScript EngineTheGet_externalThe Host application uses this call to return the distribution of an automated object.Interface. Next,Script EngineThe method that will trigger this object through the usual com automatic distribution method.