469,271 Members | 1,740 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

mouse events when the mouse is on a "child control"

red
mouse events when the mouse is on a "child control"

hi everyone;
my problem:
I have a userControl
in this usercontrol, I have a child control (a button)

when the mouse moves over the userControl, I can detect the movement using
MouseMove event.
the problem is when the mouse is on the child control : I can t detect
anything when the mouse move. userControl don t recieve the MouseMove event.

I did many search on this problem, but solutions I found are not elegant:
1- using hooks (not a part of .net platform)
2- the child control report the mouse movement to the parent control (the
userControl here)

please, can u explain me how to solve this problem?
thnks

n.b.: sorry for my english
Jul 27 '05 #1
3 9414
System always gives the previlage to listen mouse events to the last
entered control. For windows forms as you know there is a property
KeyPreview which enables Forms to receive mouse events before the
contained controls. If you make the user control listen the mouse
events; then user control can handle the mouse move. For instance, if
you press the mouse button when the mouse is on the uc, and start to
move you will see that uc is receiving mouse move events even if the
mouse is over the child control.
So you must manually mouse event listening previlage to the uc like
mouse down automatically does it for you.

Jul 28 '05 #2
how can I manually handle mouse event previlage?
thnks for ur answer
"dincerozturan" <di************@bizitek.com.tr> wrote in message
news:11********************@f14g2000cwb.googlegrou ps.com...
System always gives the previlage to listen mouse events to the last
entered control. For windows forms as you know there is a property
KeyPreview which enables Forms to receive mouse events before the
contained controls. If you make the user control listen the mouse
events; then user control can handle the mouse move. For instance, if
you press the mouse button when the mouse is on the uc, and start to
move you will see that uc is receiving mouse move events even if the
mouse is over the child control.
So you must manually mouse event listening previlage to the uc like
mouse down automatically does it for you.

Jul 29 '05 #3
For instance in the UserControl's code window handle the mouse_enter
event and write
this.Capture = true;
You will see that mouse move is captured bu usercontrol even if the
mouse is on the child control.

Hope this helps..

Jul 29 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Jeff_F | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.