I have a WPF App that is going to run on a kiosk, on a PC with a touchscreen. The App runs in fullscreen mode, to hide the OS. On one of my pages I have a WebBrowser control that allows a user to view some web pages (navigation is limited to some pages). Since the computer will be placed in a public spot I mustn't let the user access the operating system. The thing is, the touchscreen allows for a right click on the web browser, and that eventually leads to the task bar appearing... not good..!
I've been trying to disable that context menu for the past days without much success. Basically where i'm at right now is:
Added a COM reference to SHDocVw.dll to get the IWebBrowser2 interface (needed to disable the launching 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");
Fetch the 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 and disable the oncontextmenu on the document.
HTMLDocument doc = _webBrowser.Document as HTMLDocument; mshtml.HTMLDocumentEvents2_Event ev = doc as mshtml.HTMLDocumentEvents2_Event; ev.oncontextmenu += (arg) => { return false; };
So far, no sucess... any ideas?
Thanks in advance.