469,602 Members | 1,979 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

Override Mouse Events in UserControl

In a user control, is it possible to replace the default mouse events with
my own?

In particular, I want the consumer of my control to get MouseMove events
when the mouse is over my control, so that they can change the cursor.
However, my control has several standard controls on it, and the consumer of
my control only gets MouseMove events when the mouse is over the control
itself, and not when it is over the standard controls. Therefore, I want to
raise/invoke the MouseMove event myself, when the mouse moves over these
standard controls. How can I do this?

TIA

Charles
Nov 20 '05 #1
3 2801
* "Charles Law" <bl***@nowhere.com> scripsit:
In a user control, is it possible to replace the default mouse events with
In particular, I want the consumer of my control to get MouseMove events
when the mouse is over my control, so that they can change the cursor.
However, my control has several standard controls on it, and the consumer of
my control only gets MouseMove events when the mouse is over the control
itself, and not when it is over the standard controls. Therefore, I want to
raise/invoke the MouseMove event myself, when the mouse moves over these
standard controls. How can I do this?


You will have to add handlers for the embedded controls' mouse events
and call the appropriate 'MyBase.On*(sender, e)' method in the handler
in order to raise the event for the usercontrol.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
Herfried, you are the dog's doo-dahs (abstruse English compliment q.v.
"cat's pyjamas").

You clearly know stuff, but honestly, I did look all over before asking the
question. Where are such gems hidden? As far as I can tell this is not
alluded to in the MSDN, and when I looked up the error message "Derived
classes cannot raise base class events" there was no mention of the solution
you gave. Ever thought of writing a book?

Charles
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c0*************@ID-208219.news.uni-berlin.de...
* "Charles Law" <bl***@nowhere.com> scripsit:
In a user control, is it possible to replace the default mouse events with In particular, I want the consumer of my control to get MouseMove events
when the mouse is over my control, so that they can change the cursor.
However, my control has several standard controls on it, and the consumer of my control only gets MouseMove events when the mouse is over the control
itself, and not when it is over the standard controls. Therefore, I want to raise/invoke the MouseMove event myself, when the mouse moves over these
standard controls. How can I do this?


You will have to add handlers for the embedded controls' mouse events
and call the appropriate 'MyBase.On*(sender, e)' method in the handler
in order to raise the event for the usercontrol.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #3
* "Charles Law" <bl***@nowhere.com> scripsit:
Herfried, you are the dog's doo-dahs (abstruse English compliment q.v.
"cat's pyjamas").
;-)
Ever thought of writing a book?


Yes, but I don't have enough time to do that.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Laurent Lequenne | last post: by
3 posts views Thread by Raj Chudasama | last post: by
reply views Thread by Scott McChesney | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.