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. My code is very similar to webview/webview but I was unable to find help on their GitHub.
Previously, I was able to find the hWnd
for the webview and use SetWindowSubclass
to add my own wndproc
to the 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.
My goal is to create a borderless, draggable, resizeable WebView2 based app.
The problem is, that the real window that controls and gets all this input is in another process. You just see a window that shows the output in your process.
Look into Spy++. Everything below Chrome_WidgetWin_0
belongs to a new process (MSEDGEWEBVIEW2
) and is not part of your process. So you can't subclass such a window with the normal techniques.
So if you want to subclass this window. You need to inject a new DLL into this new process. This DLL might subclass the real window. And this DLL might communicate with you hosting program via any IPC.