标签: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
标签:dha protect 菜单 鼠标 pre 禁用 nothing imessage overflow
原文地址:http://www.cnblogs.com/hironpan/p/6759912.html