Resolved System.Windows.Forms.WebBrowser control and mouse back/forward

Administrator

VB.NET Forum Admin
Joined
Jun 3, 2004
Messages
1,462
Programming Experience
10+
Amazingly there are no Mouse handler events, so it seems, in the System.Windows.Forms.WebBrowser control which I use both on a form as well as within a UserControl. I need the navigation to work just like in IE where a mouse back (left) button and mouse forward (right) button are clicked.

Anyone figured out a good way to handle this?
 
WebBrowser is just a host for the various HtmlDocument objects that can be loaded, if you're not dealing with frames pages where multiple documents are loaded at the same time then you can just attach the current document and handle its events like this:
VB.NET:
Private Sub WebBrowser1_DocumentCompleted(ByVal sender As System.Object, ByVal e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles WebBrowser1.DocumentCompleted
    If Me.WebBrowser1.ReadyState = WebBrowserReadyState.Complete Then
        doc = Me.WebBrowser1.Document
    End If
End Sub

Private WithEvents doc As HtmlDocument

Private Sub doc_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.HtmlElementEventArgs) Handles doc.MouseUp
    If e.MouseButtonsPressed = Windows.Forms.MouseButtons.Left Then
        'left
    ElseIf e.MouseButtonsPressed = Windows.Forms.MouseButtons.Right Then
        'right
    End If
End Sub
 
I think those are the XButton1/XButton2 MouseButtons options, but I can't tell for sure as I can't find any documentation for this and my mice only have left/right/scroll.
 
Back
Top