You can do it with JavaScript - here's a bit of JavaScript for how we did it...
<script language="JavaScript">
var ErrMsg = "Sorry! Right Click is disabled. Please use your browser menu options.";
function disableRightClick(btnClick)
{
if (navigator.appName == "Netscape" && btnClick.which == 3) // check for netscape and right click
{
alert(ErrMsg);
return false;
}
else if (navigator.appName =="Microsoft Internet Explorer" && event.button == 2) // for IE and Right Click
{
alert(ErrMsg);
return false;
}
}
document.onmousedown = disableRightClick;
</script>
This code also takes NetScape browsers into account.
I cannot modify the HTML itself. I have created a small browser application
but I cannot have the right-click menu show up. Can I define my own and then
disable it? Will that override the default one the control has?
You can do it with JavaScript - here's a bit of JavaScript for how we did
it...
<script language="JavaScript">
var ErrMsg = "Sorry! Right Click is disabled. Please use your browser
menu options.";
function disableRightClick(btnClick)
{
if (navigator.appName == "Netscape" && btnClick.which == 3) // check for
netscape and right click
{
alert(ErrMsg);
return false;
}
else if (navigator.appName =="Microsoft Internet Explorer" && event.button
== 2) // for IE and Right Click
{
alert(ErrMsg);
return false;
}
}
document.onmousedown = disableRightClick;
</script>
This code also takes NetScape browsers into account.
Implement the IDocHostUIHandler interface and in the ShowContextMenu
function return an HRESULT of S_OK. This will prevent the context menu from
being displayed.
You can inform the WebBrowser control that you have implemented the
IDocHostUIHandler interface by getting an ICustomDoc interface from the
document, and calling SetUIHandler method with a reference to your class
that implements the interface.
Implement the IDocHostUIHandler interface and in the >ShowContextMenu
function return an HRESULT of S_OK. This will prevent the >context menu from
being displayed.
You can inform the WebBrowser control that you have >implemented the
IDocHostUIHandler interface by getting an ICustomDoc >interface from the
document, and calling SetUIHandler method with a >reference to your class
that implements the interface.
Do you know of a way / any documentation on using the IDocHostUIHandler
from VB6? I would like to pass user click events from the an HTML page
in the WebBroswer Control to my hosting VB app. Is this possible?
Unfortunately I haven't used the WebBrowser control in VB6, so I am probably
not the best person to ask. You could try one of the dedicated VB
newsgroups: microsoft.public.vb.*etc*.
Perhaps someone else here can suggest a more specific group.
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.