禁用AxWebBrowser右键菜单

Posted 皮特胖胖

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了禁用AxWebBrowser右键菜单相关的知识,希望对你有一定的参考价值。

 

出处:http://stackoverflow.com/questions/41781647/disabling-the-axwebbrowser-context-menu-vb-net

通过底层消息禁止鼠标右键消息传送到AxWebBrowser控件上,从而禁止了右键菜单。

以此类推,应该任何控件都可以用此方法禁止指定消息的传递。。

Public Class Form1
    Implements IMessageFilter

    Public Function PreFilterMessage(ByRef m As Message) As Boolean Implements IMessageFilter.PreFilterMessage
        Const WM_RBUTTONDOWN  As Integer = &H204
        Const WM_RBUTTONDBLCLK As Integer = &H206
        ‘ check that the message is WM_RBUTTONDOWN Or WM_RBUTTONDBLCLK
        ‘ verify AxWebBrowser1 is not null
        ‘ verify the target is AxWebBrowser1
        Return (m.Msg = WM_RBUTTONDOWN OrElse m.Msg = WM_RBUTTONDBLCLK) AndAlso (AxWebBrowser1 IsNot Nothing) AndAlso (AxWebBrowser1 Is Control.FromChildHandle(m.HWnd))
    End Function

    Protected Overrides Sub OnActivated(e As EventArgs)
        MyBase.OnActivated(e)
        ‘ Filter is application wide, activate filter with form
        Application.AddMessageFilter(Me)
    End Sub

    Protected Overrides Sub OnDeactivate(e As EventArgs)
        MyBase.OnDeactivate(e)
        ‘ Filter is application wide, remove when form not active
        Application.RemoveMessageFilter(Me)
    End Sub

End Class

  

以上是关于禁用AxWebBrowser右键菜单的主要内容,如果未能解决你的问题,请参考以下文章

如何在离线绘图上自定义或禁用右键菜单?

C# winform如果禁用右键菜单和其它功能键盘

jQuery禁用快捷键例如禁用F5刷新 禁用右键菜单等

如何禁用html中的右键菜单? [复制]

禁用flash右键菜单

新版CefSharp 禁用右键菜单 43.00+