Customwebrowser control

xiaoxiao2021-03-06  116

Because of the job needs, the method of customizing the WebBrowser control these days have been found. It has been studied for a while. The principle is probably known. It is basically the two interfaces that implement IDOchostuiHandler and IDOchostShowui. The IE control will call these two interfaces when appropriate. I just need to set different values ​​according to the description of the help document.

Mounting these two interface interfaces to the control, there are two ways: one is customized through the icustom interface, the code is as follows: html0.naviGate2 ("about: blank"); icustomDoc o = html0.document as icustomDoc; o. SetuiHandler (this as idochostuihandler); but because only documentation can only get the value of Document, you need to preload an empty document in advance, here is About: Blank. The second method is to complete all the interfaces required for Active Document Host, IoleClientSite, IoleinPlace, IoleDocuments //, IoleWindow // IoleInPlaceSite already contains the interface, IDochostuiHandler, IDochostShowui

// ioleinplacesite.getWindowContext call requires the following two interfaces, ioleinplaceframe //, ioleinplaceuiwindow // ioleinplaceframe has implemented the interface

// Interface IoleClientSite.getContainor needs to be used, IOLCONTAINER mounts the code in these interfaces to the controls as follows: IoleObject o = html0.getocx () as ioleObject; o.setClientSite (this as IoleClientSite); once the hook is successful, generally call follows several functions IOleInPlaceSite GetWindow IDocHostUIHandler GetHostInfo IDocHostUIHandler GetOptionKeyPath IDocHostUIHandler GetHostInfo IDocHostUIHandler getDropTarget IDocHostUIHandler UpdateUI IDocHostUIHandler ShowUI IDocHostUIHandler HideUI IDocHostUIHandler TranslateAccelerator IDocHostUIHandler TranslateUrl IDocHostUIHandler ShowContextMenu IDocHostShowUI IDocHostShowUI IOleClientSite GetContainer

There is another method that directly uses the document embedding function, embed HTMLDocument object, which can save the WebBrowser control. HTMLEDitor is the way, but unfortunately I have not been possible.

转载请注明原文地址:https://www.9cbs.com/read-125372.html

New Post(0)