'le formulaire : Option Explicit Public IndexWb As Long Private Sub Form_Load() wbMyBrowser.Navigate2 "http://google.fr" End Sub Private Sub wbMyBrowser_NavigateComplete2(ByVal pDisp As Object, URL As Variant) Dim mouseOver As clsAction Set mouseOver = New clsAction mouseOver.Set_Destination pDisp, pDisp.Document, URL, IndexWb pDisp.Document.onmouseover = mouseOver IndexWb = IndexWb + 1 Set mouseOver = Nothing End Sub 'la class Option Explicit Dim oWpDisp As WebBrowser Public WithEvents oHTMLPage As HTMLDocument Dim sURL As Variant Dim bInstantiated As Boolean Dim iIndex As Long Public Sub Class_Initialize() bInstantiated = False End Sub Public Sub Class_Terminate() Set oHTMLPage = Nothing Set oWpDisp = Nothing End Sub Public Sub Set_Destination(WpDisp As WebBrowser, HTMLPage As HTMLDocument, URL As Variant, Index As Long) Set oWpDisp = WpDisp Set oHTMLPage = HTMLPage iIndex = Index sURL = URL bInstantiated = True End Sub Private Function oHTMLPage_onclick() As Boolean oHTMLPage_onclick = False End Function Private Function oHTMLPage_oncontextmenu() As Boolean oHTMLPage_oncontextmenu = True End Function Public Sub oHTMLPage_onmouseout() Dim curElement As IHTMLEventObj2 Set curElement = oHTMLPage.parentWindow.event If Not curElement.srcElement Is Nothing Then Dim Tag As IHTMLElement Set Tag = curElement.fromElement If Tag.tagName <> "FRAME" And Tag.tagName <> "FRAMESET" And Tag.tagName <> "BODY" Then Form1.Label1.Caption = "" 'Index & "-" & curElement.Type & " " & curElement.fromElement.nodeName & " - ox=" & curElement.offsetX & " oy=" & curElement.offsetY & " - x=" & curElement.x & " y=" & curElement.y Tag.Style.BorderColor = "" Tag.Style.backgroundColor = "" Tag.Style.BorderStyle = "" Tag.Style.BorderWidth = "" End If Set Tag = Nothing End If Set curElement = Nothing End Sub Public Sub oHTMLPage_onmouseover() Dim curElement As IHTMLEventObj2 Set curElement = oHTMLPage.parentWindow.event If Not curElement.srcElement Is Nothing Then Dim Tag As IHTMLElement Set Tag = curElement.srcElement If Tag.tagName <> "FRAME" And Tag.tagName <> "FRAMESET" And Tag.tagName <> "BODY" Then Form1.Label1.Caption = iIndex & "-" & curElement.Type & " " & curElement.srcElement.nodeName & " - ox=" & curElement.offsetX & " oy=" & curElement.offsetY & " - x=" & curElement.x & " y=" & curElement.y Tag.Style.BorderColor = "#FF0000" Tag.Style.backgroundColor = "#cccccc" Tag.Style.BorderStyle = "solid" Tag.Style.BorderWidth = "1px" End If Set Tag = Nothing End If Set curElement = Nothing End Sub
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question