I need to capture all mouse events on a .NET's WebBrowser, process them and prevent the WebBrowser from getting them. Is there any way to achieve this? I wonder if there is any way I can handle mouse events if the control is disabled.
+1
A:
You'll have to override WndProc() to intercept the mouse messages. Like this:
using System;
using System.Windows.Forms;
class MyBrowser : WebBrowser {
protected override void WndProc(ref Message m) {
if (m.Msg >= 0x200 && m.Msg <= 0x20a) {
// Handle mouse messages
//...
}
else base.WndProc(ref m);
}
}
Hans Passant
2010-08-12 20:48:17