PROBLEM:
I have a WebBrowser and have exposed its ActiveX methods. In my Form in which the WebBrowser is positioned I have a MainMenuStrip with shortcuts. Only when I am typing in a textbox on my Form do the shortcuts properly work. For example, when I press CTRL + N, a shortcut of my Form - instead of a new Form opening, the page the WebBrowser is currently on opens in IE.
WHAT I'VE TRIED:
I have tried focusing the form every 100ms using a timer which didn't work (this would not be a viable option anyway as it is not very subtle and the program has to carefully navigate the WebBrowser using SendKeys etc).
Code for WebBrowser:
this.webBrowser1.WebBrowserShortcutsEnabled = false; this.webBrowser1.AllowWebBrowserDrop = false; this.webBrowser1.IsWebBrowserContextMenuEnabled = false;
Inheriting from WebBrowser and overriding ProcessCmdKey:
protected override bool ProcessCmdKey(ref Message msg, Keys keyData) { if (keyData == (Keys.Control | Keys.N)) { newToolStripMenuItem.PerformClick(); return true; // or false } }
WHAT I'M TRYING TO ACHIEVE:
That the WebBrowser's shortcuts are disabled (I read somewhere that the ActiveX prevents this...why?).
What I would like is that unless one is currently typing/navigating in the WebBrowser the Form's shortcuts work. Focus should be taken from the WebBrowser WHEREEVER there's a click outside the control, not just when other textboxes are in focus (e.g. when there's a click in the blank of the form.