Mouse capture in a third-party visual ActiveX

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
 
A

Alberto Poblacion

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;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top