定义了事件
下面是事件的触发(其他代码省略)
其中
在.net中Handles m_doc.oncontextmenu无效,不知道是什么原因
用Com通讯实现如下
HandleWebBrowserDHTMLEvents定义如下,Overridable所有Event方法
Public Event oncontextmenu()
Private Function m_doc_oncontextmenu() As Boolean Handles m_doc.oncontextmenu
RaiseEvent oncontextmenu()
m_doc_oncontextmenu = False
End Function
RaiseEvent oncontextmenu()
m_doc_oncontextmenu = False
End Function
Dim WithEvents m_doc As mshtml.HTMLDocument
用Com通讯实现如下
Dim icpc As UCOMIConnectionPointContainer
Dim g As Guid
icpc = CType(wb.Document, UCOMIConnectionPointContainer)
g = GetType(HTMLDocumentEvents2).GUID
icpc.FindConnectionPoint(g, icp)
icp.Advise(New HandleWebBrowserDHTMLEvents, cook)
m_doc = wb.Document
Dim g As Guid
icpc = CType(wb.Document, UCOMIConnectionPointContainer)
g = GetType(HTMLDocumentEvents2).GUID
icpc.FindConnectionPoint(g, icp)
icp.Advise(New HandleWebBrowserDHTMLEvents, cook)
m_doc = wb.Document
HandleWebBrowserDHTMLEvents定义如下,Overridable所有Event方法
Public Class HandleWebBrowserDHTMLEvents
Implements HTMLDocumentEvents2
Public HandleWebBrowserDHTMLEvents()
Public Overridable Sub onrowsinserted(ByVal pEvtObj As IHTMLEventObj) Implements HTMLDocumentEvents2.onrowsinserted
End Sub
Public Overridable Sub onactivate(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onactivate
End Sub
Public Overridable Sub onafterupdate(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onafterupdate
End Sub
Public Overridable Function onbeforeactivate(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.onbeforeactivate
onbeforeactivate = True
End Function
Public Overridable Function onbeforedeactivate(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.onbeforedeactivate
onbeforedeactivate = True
End Function
Public Overridable Sub onbeforeeditfocus(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onbeforeeditfocus
End Sub
Public Overridable Function onbeforeupdate(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.onbeforeupdate
onbeforeupdate = True
End Function
Public Overridable Sub oncellchange(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.oncellchange
End Sub
Public Overridable Function onclick(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.onclick
onclick = True
End Function
Public Overridable Function oncontextmenu(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.oncontextmenu
oncontextmenu = False
End Function
Public Overridable Function oncontrolselect(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.oncontrolselect
oncontrolselect = True
End Function
Public Overridable Sub ondataavailable(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.ondataavailable
End Sub
Public Overridable Sub ondatasetchanged(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.ondatasetchanged
End Sub
Public Overridable Sub ondatasetcomplete(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.ondatasetcomplete
End Sub
Public Overridable Function ondblclick(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.ondblclick
ondblclick = True
End Function
Public Overridable Sub ondeactivate(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.ondeactivate
End Sub
Public Overridable Function ondragstart(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.ondragstart
ondragstart = True
End Function
Public Overridable Function onerrorupdate(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.onerrorupdate
onerrorupdate = True
End Function
Public Overridable Sub onfocusin(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onfocusin
End Sub
Public Overridable Sub onfocusout(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onfocusout
End Sub
Public Overridable Function onhelp(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.onhelp
onhelp = True
End Function
Public Overridable Sub onkeydown(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onkeydown
End Sub
Public Overridable Function onkeypress(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.onkeypress
onkeypress = True
End Function
Public Overridable Sub onkeyup(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onkeyup
End Sub
Public Overridable Sub onmousedown(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onmousedown
End Sub
Public Overridable Sub onmousemove(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onmousemove
End Sub
Public Overridable Sub onmouseout(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onmouseout
End Sub
Public Overridable Sub onmouseover(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onmouseover
End Sub
Public Overridable Sub onmouseup(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onmouseup
End Sub
Public Overridable Function onmousewheel(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.onmousewheel
onmousewheel = True
End Function
Public Overridable Sub onpropertychange(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onpropertychange
End Sub
Public Overridable Sub onreadystatechange(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onreadystatechange
End Sub
Public Overridable Sub onrowenter(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onrowenter
End Sub
Public Overridable Function onrowexit(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.onrowexit
onrowexit = True
End Function
Public Overridable Sub onrowsdelete(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onrowsdelete
End Sub
Public Overridable Sub onselectionchange(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onselectionchange
End Sub
Public Overridable Function onselectstart(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.onselectstart
onselectstart = True
End Function
Public Overridable Function onstop(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.onstop
onstop = True
End Function
End Class
Implements HTMLDocumentEvents2
Public HandleWebBrowserDHTMLEvents()
Public Overridable Sub onrowsinserted(ByVal pEvtObj As IHTMLEventObj) Implements HTMLDocumentEvents2.onrowsinserted
End Sub
Public Overridable Sub onactivate(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onactivate
End Sub
Public Overridable Sub onafterupdate(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onafterupdate
End Sub
Public Overridable Function onbeforeactivate(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.onbeforeactivate
onbeforeactivate = True
End Function
Public Overridable Function onbeforedeactivate(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.onbeforedeactivate
onbeforedeactivate = True
End Function
Public Overridable Sub onbeforeeditfocus(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onbeforeeditfocus
End Sub
Public Overridable Function onbeforeupdate(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.onbeforeupdate
onbeforeupdate = True
End Function
Public Overridable Sub oncellchange(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.oncellchange
End Sub
Public Overridable Function onclick(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.onclick
onclick = True
End Function
Public Overridable Function oncontextmenu(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.oncontextmenu
oncontextmenu = False
End Function
Public Overridable Function oncontrolselect(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.oncontrolselect
oncontrolselect = True
End Function
Public Overridable Sub ondataavailable(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.ondataavailable
End Sub
Public Overridable Sub ondatasetchanged(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.ondatasetchanged
End Sub
Public Overridable Sub ondatasetcomplete(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.ondatasetcomplete
End Sub
Public Overridable Function ondblclick(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.ondblclick
ondblclick = True
End Function
Public Overridable Sub ondeactivate(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.ondeactivate
End Sub
Public Overridable Function ondragstart(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.ondragstart
ondragstart = True
End Function
Public Overridable Function onerrorupdate(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.onerrorupdate
onerrorupdate = True
End Function
Public Overridable Sub onfocusin(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onfocusin
End Sub
Public Overridable Sub onfocusout(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onfocusout
End Sub
Public Overridable Function onhelp(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.onhelp
onhelp = True
End Function
Public Overridable Sub onkeydown(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onkeydown
End Sub
Public Overridable Function onkeypress(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.onkeypress
onkeypress = True
End Function
Public Overridable Sub onkeyup(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onkeyup
End Sub
Public Overridable Sub onmousedown(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onmousedown
End Sub
Public Overridable Sub onmousemove(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onmousemove
End Sub
Public Overridable Sub onmouseout(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onmouseout
End Sub
Public Overridable Sub onmouseover(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onmouseover
End Sub
Public Overridable Sub onmouseup(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onmouseup
End Sub
Public Overridable Function onmousewheel(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.onmousewheel
onmousewheel = True
End Function
Public Overridable Sub onpropertychange(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onpropertychange
End Sub
Public Overridable Sub onreadystatechange(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onreadystatechange
End Sub
Public Overridable Sub onrowenter(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onrowenter
End Sub
Public Overridable Function onrowexit(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.onrowexit
onrowexit = True
End Function
Public Overridable Sub onrowsdelete(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onrowsdelete
End Sub
Public Overridable Sub onselectionchange(ByVal e As IHTMLEventObj) Implements HTMLDocumentEvents2.onselectionchange
End Sub
Public Overridable Function onselectstart(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.onselectstart
onselectstart = True
End Function
Public Overridable Function onstop(ByVal e As IHTMLEventObj) As Boolean Implements HTMLDocumentEvents2.onstop
onstop = True
End Function
End Class