469,608 Members | 2,163 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,608 developers. It's quick & easy.

Mouse capture in a third-party visual ActiveX

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
May 12 '07 #1
2 2785
"P. Meyer" <ph*************@wanadoo.frwrote in message
news:46***********************@news.orange.fr...
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;
}
}

May 12 '07 #2
Thanks Alberto
Philippe
May 13 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Logan Mckinley | last post: by
8 posts views Thread by NeoAsimov | last post: by
4 posts views Thread by Henry Wu | last post: by
3 posts views Thread by Dave | last post: by
2 posts views Thread by Sam | last post: by
reply views Thread by guiromero | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.