I have a WPF application that will work in a kiosk, on a touch screen PC. The application runs in full screen mode to hide the OS. On one of my pages, I have a WebBrowser control that allows the user to browse some web pages (navigation is limited to certain pages). Since the computer will be located in an open place, I should not allow the user to access the operating system. The fact is that the touch screen allows you to right-click in a web browser, and this ultimately leads to the appearance of the taskbar ... not good ..!
I have been trying to disable this context menu for the past days without much success. Basically where I am now:
Added COM link to SHDocVw.dll to get IWebBrowser2 interface (you need to disable the launch of new windows.
[ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] [Guid("6d5140c1-7436-11ce-8034-00aa006009fa")] internal interface IServiceProvider { [return: MarshalAs(UnmanagedType.IUnknown)] object QueryService(ref Guid guidService, ref Guid riid); } static readonly Guid SID_SWebBrowserApp = new Guid("0002DF05-0000-0000-C000-000000000046");
Get IWEbBrowser2 Interface
IServiceProvider _serviceProvider = null; if (_browser.Document != null) { _serviceProvider = (IServiceProvider)_browser.Document; Guid _serviceGuid = SID_SWebBrowserApp; Guid _iid = typeof(SHDocVw.IWebBrowser2).GUID; SHDocVw.IWebBrowser2 _webBrowser = (SHDocVw.IWebBrowser2)_serviceProvider.QueryService(ref _serviceGuid, ref _iid);
And try disabling oncontextmenu in the document.
HTMLDocument doc = _webBrowser.Document as HTMLDocument; mshtml.HTMLDocumentEvents2_Event ev = doc as mshtml.HTMLDocumentEvents2_Event; ev.oncontextmenu += (arg) => { return false; };
Still no sucess ... any ideas?
Thanks in advance.
Filipe miguel
source share