码迷,mamicode.com
首页 > Windows程序 > 详细

winform屏蔽鼠标右键

时间:2019-11-04 18:05:21      阅读:180      评论:0      收藏:0      [点我收藏+]

标签:右键   icon   smi   mod   dismiss   fsharp   smis   control   handler   

        /// <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屏蔽鼠标右键

标签:右键   icon   smi   mod   dismiss   fsharp   smis   control   handler   

原文地址:https://www.cnblogs.com/teng-0802/p/11792993.html

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