Mouse capture in a third-party visual ActiveX

  • Thread starter Thread starter P. Meyer
  • Start date Start date
P

P. Meyer

Hi

I need to capture a mouse click event when inside a visual third party
ActiveX which unfortunately comes without published events.

In Win32 I used to manage such problems on Application level with WM_
messages, but almost beginner in .NET & C# environment, I don't see the
solution, which is probably trivial for experienced people.

Any help?

Thanks in advance.

Philippe
 
P. Meyer said:
I need to capture a mouse click event when inside a visual third party
ActiveX which unfortunately comes without published events.

In Win32 I used to manage such problems on Application level with WM_
messages, but almost beginner in .NET & C# environment, I don't see the
solution, which is probably trivial for experienced people.

You can also catch the WM_ messages in .Net. During program startup, you
add a message filter:

System.Windows.Forms.Application.AddMessageFilter(new MyFilterClass());

You then add a class that implements IMessageFilter to process the
messages. The following example processes a key press, but you can use a
similar technique to process mouse clicks:

class MyFilterClass: IMessageFilter
{
private const int WM_KEYDOWN = 0x100;

public bool PreFilterMessage(ref Message m)
{
if (m.Msg == WM_KEYDOWN)
{
Keys key= (Keys)(int)m.WParam & Keys.KeyCode;
if (key==Keys.Decimal)
{
SendKeys.Send(",");
return true;
}
}

return false;
}
}
 
Back
Top