How can I disable the context menu in the WebBrowser control? I'm using this control in a VB6 application to display an HTML file, but I don't want the user to get the context menu if they happen to right click on the control. Thanks.
I managed to find the answer to my own question and figured I'd post it in case anyone else needs it. First you set a reference in the project to Microsoft HTML Object Library. Then use the following code where BrowCtl is the name of your WebBrowser control:
'Declare a variable for the document property of
'the WebBrowser control
Private WithEvents htmlDoc As HTMLDocument
'Set the variable equal to the WebBrowser's
'document property
Private Sub brwLog_DocumentComplete(ByVal pDisp As Object, _ URL As Variant)
Set htmlDoc = BrowCtl.Document
End Sub
'Disable the document's oncontextmenu event
Private Function htmlDoc_oncontextmenu() As Boolean
htmlDoc_oncontextmenu = False
End Function
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.