winform屏蔽鼠标右键
Posted teng-0802
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了winform屏蔽鼠标右键相关的知识,希望对你有一定的参考价值。
/// <summary> /// 屏蔽右键 /// </summary> internal class MenuHandler : IContextMenuHandler { public bool OnBeforeContextMenu(IWebBrowser browser, IBrowser ibrower, IFrame iframe, IContextMenuParams icontextmenuparams, IMenuModel imenumodel) { return false; } void CefSharp.IContextMenuHandler.OnBeforeContextMenu(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame, CefSharp.IContextMenuParams parameters, CefSharp.IMenuModel model) { model.Clear(); } bool CefSharp.IContextMenuHandler.OnContextMenuCommand(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame, CefSharp.IContextMenuParams parameters, CefSharp.CefMenuCommand commandId, CefSharp.CefEventFlags eventFlags) { //throw new NotImplementedException(); return false; } void CefSharp.IContextMenuHandler.OnContextMenuDismissed(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame) { //throw new NotImplementedException(); } bool CefSharp.IContextMenuHandler.RunContextMenu(CefSharp.IWebBrowser browserControl, CefSharp.IBrowser browser, CefSharp.IFrame frame, CefSharp.IContextMenuParams parameters, CefSharp.IMenuModel model, CefSharp.IRunContextMenuCallback callback) { return false; } }
使用:在form中初始化即可
_browser.MenuHandler = new MenuHandler();
以上是关于winform屏蔽鼠标右键的主要内容,如果未能解决你的问题,请参考以下文章