简体   繁体   English

从 Webview2 (Edge/Chromium) 拦截 Windows 消息

[英]Intercepting Windows Messages from Webview2 (Edge/Chromium)

I have recently migrated a project of mine to WebView2 and the last part I can't figure out is how to intercept the Windows Messages for the webview.我最近将我的一个项目迁移到WebView2 ,我不知道的最后一部分是如何拦截 webview 的 Windows 消息。 My code is very similar to webview/webview but I was unable to find help on their GitHub.我的代码与webview/webview非常相似,但我无法在他们的 GitHub 上找到帮助。

Previously, I was able to find the hWnd for the webview and use SetWindowSubclass to add my own wndproc to the webview.以前,我能够找到 webview 的hWnd并使用SetWindowSubclass将我自己的wndproc添加到 webview。 However, I've used Spy++ and tried SetWindowSubclass on all the windows that showed up there (see below) but none of them had any windows messages in my wndproc other than some window management ones I did not think were useful - The best I got was WM_PARENTYNOTIFY , but I am interested in WM_MOUSEMOVE and WM_NCHITTEST - neither of which I could find.但是,我已经使用Spy++并在所有出现在那里的 windows 上尝试了SetWindowSubclass (见下文),但除了一些 Z05B8C74CBD97FBF2DEZ4 最好的管理我认为没有用 IF4 没有任何 windows 消息在我的wndproc中是WM_PARENTYNOTIFY ,但我对WM_MOUSEMOVEWM_NCHITTEST感兴趣 - 我都找不到。

My goal is to create a borderless, draggable, resizeable WebView2 based app.我的目标是创建一个基于 WebView2 的无边界、可拖动、可调整大小的应用程序。

间谍++输出

The problem is, that the real window that controls and gets all this input is in another process.问题是,控制和获取所有这些输入的真正 window 位于另一个进程中。 You just see a window that shows the output in your process.您只看到 window 显示您的进程中的 output。

Look into Spy++.调查间谍++。 Everything below Chrome_WidgetWin_0 belongs to a new process ( MSEDGEWEBVIEW2 ) and is not part of your process. Chrome_WidgetWin_0下的所有内容都属于一个新进程 ( MSEDGEWEBVIEW2 ),并且不属于您的进程。 So you can't subclass such a window with the normal techniques.因此,您不能使用常规技术对此类 window 进行子类化。

So if you want to subclass this window.所以如果你想继承这个 window。 You need to inject a new DLL into this new process.您需要在这个新进程中注入一个新的 DLL。 This DLL might subclass the real window.这个 DLL 可能是真正的 window 的子类。 And this DLL might communicate with you hosting program via any IPC.而这个 DLL 可以通过任何 IPC 与您的托管程序进行通信。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM