Managing key events in a WebBrowser control?

I am currently using an application that plays ppt and performs flash control in WebBrowser Control.

In WebBrowser, I can hide the context menu with

 this.IsWebBrowserContextMenuEnabled = false; 

and capture the key event using

 this.PreviewKeyDown += new PreviewKeyDownEventHandler(IWebBrowser_PreviewKeyDown); 

but when playing ppt , both the context menu and the keystroke events do not work, that is, I see the context menu and arrow to make ppt change the slide.

Again, during flash playback, the context menu is displayed, and I can handle the key event. is there any other setting for it, is the same for any ( HTML , ppt , Flash , PDF ) reproduced in webBrowser?

Edit: 1 Here is my existing code

 class IWebBrowser : WebBrowser public IWebBrowser(RegionOptions options) { try { this.Width = 600; this.Height = 400; this.IsWebBrowserContextMenuEnabled = false; this.ScrollBarsEnabled = false; this.ScriptErrorsSuppressed = true; this.WebBrowserShortcutsEnabled = false; this.AllowNavigation = true; CreateContextMenu(); this.DocumentCompleted += new WebBrowserDocumentCompletedEventHandler(IWebBrowser_DocumentCompleted); this.PreviewKeyDown += new PreviewKeyDownEventHandler(IWebBrowser_PreviewKeyDown); } catch (Exception ex) { log.Error("IWebBrowser - ctor ", ex); } } private void CreateContextMenu() { ContextMenuStrip myContextMenu = new ContextMenuStrip(); this.ContextMenuStrip = myContextMenu; ToolStripMenuItem myFirstTooltip = new ToolStripMenuItem(); ToolStripMenuItem mySecondTooltip = new ToolStripMenuItem(); ToolStripMenuItem myThirdTooltip = new ToolStripMenuItem(); myFirstTooltip.Text = "Item One"; mySecondTooltip.Text = "Item Two"; myThirdTooltip.Text = "Item Three"; myContextMenu.Items.Add(myFirstTooltip); myContextMenu.Items.Add(mySecondTooltip); myContextMenu.Items.Add(myThirdTooltip); } 

context menu Images for various controls reproduced in webbrowser
Show web page ..................
Contextmenu webpage
flash played in a web browser .................
Context menu in flash (displayed in webbrowser)
ppt played webbrowser .....................
Context menu in PPT (displayed in webbrowser)

+3
c # flash powerpoint webbrowser-control
Sep 17 '14 at 7:34
source share
3 answers

Override all mouse event flags Here is an example I hope this example helps you

+1
Sep 29 '14 at 6:54
source share

Follow these steps to get rid of the default context menu.

  • Do what you did to hide the default context menu

    this.IsWebBrowserContextMenuEnabled = false;

  • Add a ContextMenuStrip control to your window and give a name (say MyMenu)

  • Set the ContextMenuStrip property for MyMenu for your browser

Now, regardless of the type of document displayed in your browser, it will only display your user menu.

Hope this helps!

All the best

+2
Sep 26 '14 at 13:38
source share

You have to catch the PreviewKeyDown event in your WebControl where your ppt / flash is playing, and pick it up on the content page or something else.

You can check how: define a custom event for WebControl in asp.net

0
Sep 26 '14 at 13:44 on
source share



All Articles