Context
In a C# Windows Forms application for Win7 we host an ActiveX control. So far, so good.
Need: prevent ActiveX to receive mouse events
Actually, the ActiveX has too much functionality. It is not very customizable to turn off features we don't need.
It would be nice if we just prevented it from receiving mouse events.
The ideal would be to just treat events as if the ActiveX was not there, that is the mouse clicks go right through to the underlying (or containing) Control.
But if we just prevent the ActiveX from getting events that would be okay with us.
Search before you ask
Some answers to previous questions mention to protected override void WndProc(ref Message m)
, e.g. c# - Pass-through mouse events to parent control - Stack Overflow
Other mentions to implement IMessageFilters, e.g.:
- winforms - C# Application-Wide Left Mouse Click Event - Stack Overflow
- winforms - Handling a click event anywhere inside a panel in C# - Stack Overflow
- winforms - C# Application-Wide Left Mouse Click Event - Stack Overflow
- Capturing Mouse Events from every component on C# WInForm - Stack Overflow
Experiment: ActiveX still gets events
I have fairly extensively tried both override WndProc
and IMessageFilter
ways, filtering (opt-in and opt-out) a number of events. In some cases I can prevent events to reach native C# controls, but the ActiveX still got its share.
Filtering too much, prevented controls and ActiveX to paint, or even application to draw properly or caused crash on exit. This can be averted by selecting opt-in or opt-out options carefully.
Is there another way?
Is there another way from C#/.NET to host an ActiveX Control while preventing it from getting mouse events? Perhaps at application start time?