To be honest, the final solution is to implement the idochostuihandler interface and solve it in the gethostinfo method. However, the "Implementation interface" means that the QueryInterface, addref, and release methods must be implemented, so the relevant code is:
Class cmywebbrowser: Public idochostuihandler
{
Public:
Cmywebbrowser () {m_cref = 0 ;}
Virtual ~ Cmywebbrowser (){}
Long m_cref;
PRIVATE:
Hresult stdmethodcalltype QueryInterface (refiid riid, void ** ppvobject)
{
Hresult result = s_ OK;
If (isbadwriteptr (ppvobject, sizeof (lpvoid )))
Result = e_invalidarg;
If (result = s_ OK)
{
* Ppvobject = NULL;
If (isequaliid (riid, iid_iunknown ))
* Ppvobject = this;
// Else if (isequaliid (riid, iid_ioleclientsite ))
// * Ppvobject = (ioleclientsite *) This;
Else if (isequaliid (riid, iid_idochostuihandler ))
* Ppvobject = (idochostuihandler *) This;
Else
Result = e_nointerface;
}
If (result = s_ OK)
This-> addref ();
Return result;
}
Ulong stdmethodcalltype addref (){
Interlockedincrement (& m_cref );
Return m_cref;
}
Ulong stdmethodcalltype release (){
Ulong ulrefcount = interlockeddecrement (& m_cref );
Return ulrefcount;
}
Hresult stdmethodcalltype enablemodeless (bool fenable) {return s_ OK ;}
Hresult stdmethodcalltype filterdataobject (idataobject * PDO, idataobject ** ppdoret) {return s_ OK ;}
Hresult stdmethodcalltype getdroptarget (idroptarget * pdroptarget, idroptarget ** ppdroptarget) {return s_ OK ;}
Hresult stdmethodcalltype getexternal (idispatch ** ppdispatch) {return s_ OK ;}
Hresult stdmethodcalltype getoptionkeypath (lpolestr * pchkey, dword dw) {return s_ OK ;}
Stdmethod (gethostinfo) (dochostuiinfo * pinfo ){
Pinfo-> cbsize = sizeof (dochostuiinfo );
Pinfo-> dwflags | = dochostuiflag_no3dborder;
Pinfo-> dwdoubleclick = dochostuidblclk_default;
Pinfo-> pchhostcss = 0;
Pinfo-> pchhostns = 0;
Return s_ OK;
}
Hresult stdmethodcalltype hideui (void) {return s_ OK ;}
Hresult stdmethodcalltype ondocwindowactivate (bool factivate) {return s_ OK ;}
Hresult stdmethodcalltype onframewindowactivate (bool factivate) {return s_ OK ;}
Hresult stdmethodcalltype resizeborder (lpcrect prcborder, ioleinplaceuiwindow * puiwindow, bool fframewindow) {return s_ OK ;}
Hresult stdmethodcalltype showcontextmenu (DWORD dwid, point * PPT, iunknown * pcmdtreserved, idispatch * pdispreserved) {return s_ OK ;}
Hresult stdmethodcalltype showui (DWORD dwid,
Ioleinplaceactiveobject * pactiveobject,
Iolecommandtarget * pcommandtarget,
Ioleinplaceframe * pframe,
Ioleinplaceuiwindow * pdoc
) {Return s_ OK ;}
Hresult stdmethodcalltype translateaccelerator (lpmsg,
Const guid * pguidcmdgroup,
DWORD n1_id
)
{Return s_ OK ;}
Hresult stdmethodcalltype translateurl (DWORD dwtranslate,
Olechar * pchillin,
Olechar ** ppchillout
)
{Return s_ OK ;}
Hresult stdmethodcalltype updateui (void) {return s_ OK ;}
};
1. A more general point to be written is that the above class is just like this, and then webbrowser inherits from this class.
2. In addition to implementing this interface, do not forget setuihandler. This is not hard to find, and it will not be written here.
Complain: webbrowser is used in the project. Since only one of the project team has done Web, this is my maintenance. Recently, I added doctype to the HTML file, as a result, the webbrowser has a 3D border. No matter whether it is the CSS border: 0 or the leftmargin and topmargin of the body, it does not work. I checked a lot of information (mainly from Google foreigners ), it is said that the idochostuihandler interface can be implemented. In the gethostinfo method, the 3D border can be killed. However, according to what I did on the Internet, the result is either an error, or the gethostinfo does not go away. I am depressed and have been tossing for two days, in the end, I still think that QueryInterface and other three methods should be implemented, and the results should be checked. After implementation, we can get it done ~~~