To put it simply, the idochostuihandler interface is implemented. The interface attached with the idochostuihandler interface can be implemented using the icustomdoc interface or the ioleobject interface. Here we demonstrate the use of the icustomdoc interface for mounting. To shield the webbroswer pop-up menu, you only need to write an article on the showcontextmenu method of the idochostuihandler. Other methods of the idochostuihandler do not need to be processed, but you must implement them, even if you only write some comments, let's look at the code below:
'Button on the form, a tetbox, a checkbox, and a webbrowser
'Here I still reference edanmo's Ole interfaces & functions v1.81 (corresponding file olelib. TLB)
Option explicit
Implements idochostuihandler
Dim mshow as Boolean
Dim micustomdoc as icustomdoc
Private sub checkduplicate click ()
Mshow = check1.value
End sub
Private sub commandementclick ()
Me. webbrowser1.navigate text1.text
End sub
Private sub form_load ()
Me. webbrowser1.navigate "about: blank"
End sub
Private sub idochostuihandler_enablemodeless (byval fenable as olelib. bool)
Idochostuihandler. enablemodeless fenable
End sub
Private function idochostuihandler_filterdataobject (byval PDO as olelib. idataobject) as olelib. idataobject
Set idochostuihandler_filterdataobject = idochostuihandler. filterdataobject (PDO)
End Function
Private function idochostuihandler_getdroptarget (byval pdroptarget as olelib. idroptarget) as olelib. idroptarget
Set idochostuihandler_getdroptarget = idochostuihandler. getdroptarget (pdroptarget)
End Function
Private function idochostuihandler_getexternal () as object
Set idochostuihandler_getexternal = idochostuihandler. getexternal
End Function
Private sub idochostuihandler_gethostinfo (pinfo as olelib. dochostuiinfo)
Idochostuihandler. gethostinfo pinfo
End sub
Private sub idochostuihandler_getoptionkeypath (polestrchkey as long, byval DW as long)
Idochostuihandler. getoptionkeypath polestrchkey, DW
End sub
Private sub idochostuihandler_hideui ()
Idochostuihandler. hideui
End sub
Private sub idochostuihandler_ondocwindowactivate (byval factivate as olelib. bool)
Idochostuihandler. ondocwindowactivate factivate
End sub
Private sub idochostuihandler_onframewindowactivate (byval factivate as olelib. bool)
Idochostuihandler. onframewindowactivate factivate
End sub
Private sub idochostuihandler_resizeborder (prcborder as olelib. rect, byval puiwindow as olelib. ioleinplaceuiwindow, byval framewindow as olelib. bool)
Idochostuihandler. resizeborder prcborder, puiwindow, framewindow
End sub
Private sub idochostuihandler_showcontextmenu (byval dwcontext as olelib. contextmenutarget, Ppoint as olelib. Point, byval pcommandtarget as olelib. iolecommandtarget, byval htmltagelement as object)
If mshow = true then
Idochostuihandler. showcontextmenu dwcontext, Ppoint, pcommandtarget, htmltagelement
End if
End sub
Private sub partition (byval dwid as long, byval pactiveobject as olelib. Large, byval pcommandtarget as olelib. iolecommandtarget, byval pframe as olelib. ioleinplaceframe, byval pdoc as olelib. Large)
Idochostuihandler. showui dwid, pactiveobject, pcommandtarget, pframe, pdoc
End sub
Private sub idochostuihandler_translateaccelerator (lpmsg as olelib. MSG, pguid1_group as olelib. UUID, byval n1_id as long)
Idochostuihandler. translateaccelerator lpmsg, pguid1_group, n1_id
End sub
Private function idochostuihandler_translateurl (byval dwtranslate as long, byval pchillin as long) as long
Idochostuihandler_translateurl = idochostuihandler. translateurl (dwtranslate, pchillin)
End Function
Private sub idochostuihandler_updateui ()
Idochostuihandler. updateui
End sub
Private sub webbrowser1_downloadcomplete ()
Set micustomdoc = me. webbrowser1.document
Micustomdoc. setuihandler me
End sub
Finally, it should be noted that this program may have some problems, so that it cannot work well in the vb ide (to what's the reason, I have no time to study it now. Let's talk about it later, you know, please tell me). However, after compiling it into an EXE file, it can still achieve our goal.