禁用AxWebBrowser右鍵菜單

來源:互聯網
上載者:User

標籤: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 SubEnd Class

  

禁用AxWebBrowser右鍵菜單

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.