码迷,mamicode.com
首页 > Web开发 > 详细

禁用AxWebBrowser右键菜单

时间:2017-04-25 10:19:04      阅读:238      评论:0      收藏:0      [点我收藏+]

标签:dha   protect   菜单   鼠标   pre   禁用   nothing   imessage   overflow   

 

出处: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右键菜单

标签:dha   protect   菜单   鼠标   pre   禁用   nothing   imessage   overflow   

原文地址:http://www.cnblogs.com/hironpan/p/6759912.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!