Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / July 2006

Tip: Looking for answers? Try searching our database.

Capturing mouse event at higher level in containment hierarchy

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
illegal.prime@gmail.com - 10 Jul 2006 21:07 GMT
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
illegal.prime@gmail.com - 11 Jul 2006 00:43 GMT
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

> 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
[quoted text clipped - 7 lines]
> Thanks,
> Novice
Stoitcho Goutsev (100) - 11 Jul 2006 14:06 GMT
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/bro
wse_thread/thread/d3b3044c423df7ec/606da6abeae4716a?lnk=st&q=IMessageFilter+Stoi
tcho&rnum=2&hl=en#606da6abeae4716a


Signature

HTH
Stoitcho Goutsev (100)

> 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
[quoted text clipped - 7 lines]
> Thanks,
> Novice

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.