[英]Disable WebBrowser contextmenu
如何禁用WPF WebBrowser-Control的standard-context菜單?
使用mshtml;
private mshtml.HTMLDocumentEvents2_Event documentEvents;
在構造函數或xaml中設置您的LoadComplete事件:
webBrowser.LoadCompleted += webBrowser_LoadCompleted;
然后在該方法中創建新的Webbrowser文檔對象,並查看可用屬性並創建新事件,如下所示:
private void webBrowser_LoadCompleted(object sender, NavigationEventArgs e)
{
documentEvents = (HTMLDocumentEvents2_Event)webBrowserChat.Document; // this will access the events properties as needed
documentEvents.oncontextmenu += webBrowserChat_ContextMenuOpening;
}
private bool webBrowserChat_ContextMenuOpening(IHTMLEventObj pEvtObj)
{
return false; // ContextMenu wont open
// return true; ContextMenu will open
// Here you can create your custom contextmenu or whatever you want
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.