Subscribe to all MouseMove event controls (note that they are recursive for nested controls)
foreach (Control control in Controls) control.MouseMove += RedirectMouseMove;
And raise MouseMove inside this event handler
private void RedirectMouseMove(object sender, MouseEventArgs e) { Control control = (Control)sender; Point screenPoint = control.PointToScreen(new Point(eX, eY)); Point formPoint = PointToClient(screenPoint); MouseEventArgs args = new MouseEventArgs(e.Button, e.Clicks, formPoint.X, formPoint.Y, e.Delta); OnMouseMove(args); }
Keep in mind that controls receive MouseEvents with local control coordinates. Therefore, you need to convert it to a coordinate form. There may be flaws with the nested controls, but I leave them to you (e.g. calling Parent.PointToClient)
UPDATE: you can still handle management events - just subscribe to the event again.
Sergey Berezovskiy
source share