Capturing mouse event at higher level in containment hierarchy


I

illegal.prime

Hey all, I have fairly deep nesting of controls in my Form. At a
relatively high level in this hierarchy I would like to react to mouse
click, mouse down, mouse up events.

But the events don't seem to perculate up through the containment
hierarchy.

Any suggestions?

Thanks,
Novice
 
Ad

Advertisements

I

illegal.prime

So it looks like the only way to get this to work is to add a listener
to the contained control's Enter event. Apparently if you add a
Control (an object whose class extends Control) named X to a Panel,
UserControl, etc named Y. And then if you want to listen to mouse
events (movement, click, etc) on X, you need to get a reference to the
X and listen to the appropriate mouse event on X.

Hope that helps someone else out there,
Novice
 
Ad

Advertisements

S

Stoitcho Goutsev \(100\)

Hi,

No event does not perculate. Each control has its own surface and the mouse
events are sent to the window (control) under the mouse cursor. Windows
forms doesn't support event bubbling. Upcoming WPF will support event
bubbling and event tunneling which will allow events going up and down in
the controil hierarchy.
For now what you can do is to use message filters. Windows mouse messages
comes through the message queue so they can be handled on the level of the
application.

The following is a thread where I heve posted some sample code:

http://groups.google.ca/group/microsoft.public.dotnet.framework.windowsforms/browse_thread/thread/d3b3044c423df7ec/606da6abeae4716a?lnk=st&q=IMessageFilter+Stoitcho&rnum=2&hl=en#606da6abeae4716a
 

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