简体   繁体   English

如何截获CefSharp.WinForms.ChromiumWebBrowser的WndProc消息?

[英]How can I intercept WndProc messages of CefSharp.WinForms.ChromiumWebBrowser?

In order to intercept the WndProc messages of the CefSharp.WinForms.ChromiumWebBrowser control I'm using a derived class so I can use Protected Overrides Sub WndProc(ByRef m As Message) . 为了拦截CefSharp.WinForms.ChromiumWebBrowser控件的WndProc消息,我使用派生类,因此可以使用Protected Overrides Sub WndProc(ByRef m As Message)

I have two issues: 我有两个问题:

  1. I'm not receiving all messages (eg WM_MOUSEWHEEL) 我没有收到所有消息(例如WM_MOUSEWHEEL)
  2. Clicking on the control causes a message with the value 528 (=0x210) rather than the expected 513 (= 0x201 = WM_LBUTTONDOWN). 单击控件将导致消息值为528(= 0x210),而不是预期的513(= 0x201 = WM_LBUTTONDOWN)。

Searching for answers I stumbled across the following SO answer ( https://stackoverflow.com/a/20489430/4247806 ) which offered an explanation and a solution, but it appears quite complicated for a task that shouldn't be that unusual. 在寻找答案时,我偶然发现了以下SO答案( https://stackoverflow.com/a/20489430/4247806 ),该答案提供了解释和解决方案,但是对于一项不应该那么寻常的任务而言,它显得相当复杂。 I also didn't get it working for my CEF version, (CEF 3.2454.1344.g2782fb8, Chromium 45.0.2454.101 and .net 4.5.1.). 我也没有在我的CEF版本上使用它(CEF 3.2454.1344.g2782fb8,Chromium 45.0.2454.101和.net 4.5.1。)。

Concrete questions would be: 具体问题是:

  1. Why aren't all messages "forwarded"? 为什么不是所有邮件都“转发”?
  2. Why is the "mouse button down message" (and others) different? 为什么“鼠标按下消息”(和其他消息)不同?

Help would, obviously, be great ;) 很明显,帮助会很棒;)

The answer you have linked to is basically correct, the default is to run the message loop in a different thread, which makes it difficult to receive messages. 您链接到的答案基本上是正确的,默认设置是在另一个线程中运行消息循环,这使得接收消息变得困难。 You can use a NativeWindow to hook the relevant process, see https://github.com/cefsharp/CefSharp/blob/cefsharp/47/CefSharp.WinForms.Example/ChromeWidgetMessageInterceptor.cs#L22 for an example. 您可以使用NativeWindow挂钩相关过程,有关示例,请参见https://github.com/cefsharp/CefSharp/blob/cefsharp/47/CefSharp.WinForms.Example/ChromeWidgetMessageInterceptor.cs#L22 Download the source to see it in action. 下载源代码以查看实际运行情况。

The other option is to use the existing WinForms message loop, see https://github.com/cefsharp/CefSharp/commit/fe11f2eada542f49e4eef0feed9b2b0978446bbf#diff-f142d024925e73816b0fabd620d2f71d for an example (Download the source code and step through if you have trouble following which pieces need to be set). 另一种选择是使用现有的WinForms消息循环,有关示例,请参见https://github.com/cefsharp/CefSharp/commit/fe11f2eada542f49e4eef0feed9b2b0978446bbf#diff-f142d024925e73816b0fabd620d2f71d (如果遇到问题,请下载源代码并逐步进行操作)需要设置)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 CefSharp.WinForms.ChromiumWebBrowser自定义权限上下文菜单 - CefSharp.WinForms.ChromiumWebBrowser custom right context menu cefsharp ChromiumWebBrowser,我如何将 json object 返回到 javascript,而不是字符串 - cefsharp ChromiumWebBrowser,how can i return json object to javascript,not string 如何在用户控件中拦截父窗体的 wndproc - How can I intercept wndproc of parent form in usercontrol CefSharp ChromiumWebBrowser专用浏览器C#winforms - CefSharp ChromiumWebBrowser private browser C# winforms 我可以让CefSharp WPF ChromiumWebBrowser接受IME输入吗? - Can I get the CefSharp WPF ChromiumWebBrowser to accept IME input? 如何在没有任何内容的情况下拦截来自HwndSource的WndProc消息 - How to intercept WndProc messages from a HwndSource without any content CefSharp.WinForms "Dock =DockStyle.Fill" 没效果,黑边。如何让ChromiumWebBrowser填充TBForm? - CefSharp.WinForms "Dock =DockStyle.Fill" no effect, black edge.how to make the ChromiumWebBrowser fill the TBForm? 为什么在加载 state 时保留 ChromiumWebBrowser 表单 CefSharp/WinForms - Why keeps the ChromiumWebBrowser form CefSharp/WinForms in loading state 如何在 WPF 中在运行时创建 CefSharp ChromiumWebBrowser - How to create CefSharp ChromiumWebBrowser at runtime in WPF 折叠时如何使用 ChromiumWebBrowser - How can I use a ChromiumWebBrowser when Collapsed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM