472,371 Members | 1,522 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,371 software developers and data experts.

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 2979
* "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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: red | last post by:
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...
0
by: Laurent Lequenne | last post by:
Hello there, I'm trying to capture mouse events on a usercontrol as a Listview does not generate any mouse event when it is outside the client zone (Border / Scrollbar) . To do that I would like...
3
by: Raj Chudasama | last post by:
i have a custom control derived from usercontrol (called popupwin). I have another usercontrol (called extensionbutton). In the extension button i have declared a variable as follows: private...
0
by: 6tc1 | last post by:
Hi all, I've got a UserControl that contains a few PictureBox objects. If I click on outside of the Picture in the UserControl, the scrolling with the mouse button works - however, no amount of...
0
by: Scott McChesney | last post by:
I have a problem I hope you folks can help me with. I have an application that is using a tab-based interface, with the ability for users to drag an item from a ListBox onto the tab control. ...
4
by: ronchese | last post by:
Hello! I have a UserControl that have two other controls inside it. I need to set a different border color for my UserControl when the mouse enters it, and restore the border color when the...
0
by: hmm | last post by:
Hi all I have two problems: Problem #1: I'm using a .NET Form with the property 'FormBorderStyle' set to 'None'. The idea is to completely cover the area of that Form with a UserControl. In...
2
by: Maciej S | last post by:
Hi, I would like to move a UserControl in a drag-and-drop way (user clicks on control and while the button is down the control changes its location fallowing the mouse). I start the drag...
3
by: Zabto | last post by:
I created an array of 8X5 boxes to represents pixels in a character. Each box is a custom UserControl of a fixed size which is filled black if it's activated, or white if it's not. I wanted to...
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python has gained popularity among beginners and experts...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...
1
by: ezappsrUS | last post by:
Hi, I wonder if someone knows where I am going wrong below. I have a continuous form and two labels where only one would be visible depending on the checkbox being checked or not. Below is the...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.