WinFormsHTMLChromium icon indicating copy to clipboard operation
WinFormsHTMLChromium copied to clipboard

About KeyEvent Solution!

Open jerviscui opened this issue 9 years ago • 2 comments

Hi! Man

I find a solution for the ChromiumWebBrowser KeyEvent with WinForm.

I read the blog http://www.codeproject.com/Articles/990346/Using-HTML-as-UI-Elements-in-a-WinForms-Applicatio, and you refer

[As a side-note, I initially attempted to catch the F12 key on the form, however even with KeyPreview set to true, it seemed Chrome caught all key strokes and the key preview was never caught by the WinForm class.]

  1. bind the PreviewKeyDown event and set the KeyboardHandler to a Class which implement IKeyboardHandler
  2. in IKeyboardHandler.OnPreKeyEvent(IWebBrowser browserControl,...) method, I call the Control.PreProcessControlMessage(ref Message msg) for send message to the PreviewKeyDown event
  3. Just OK.
Mail to me, friend.

jerviscui avatar Jul 11 '16 07:07 jerviscui

Hi Jerviscui.

Thanks for your note and this info. That's great. When I am next in this project area I will update the code with your solution.

OceanAirdrop avatar Jul 24 '16 11:07 OceanAirdrop

Excuse me! Can you tell me how to trigger KeyPressEvent by CefSharp, I want IKeyboardHandler execute that, but doesn't work. Do you have any good idea? Thx.

jerviscui avatar Jul 25 '16 09:07 jerviscui