[英]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: 我有两个问题:
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: 具体问题是:
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.