473,698 Members | 2,153 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3102
* "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*(sen der, 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*(sen der, 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
10625
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 userControl, I can detect the movement using MouseMove event. the problem is when the mouse is on the child control : I can t detect
0
1738
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 to use the EnableNotifyMessage and the OnNotifyMessage(Message m) method. It works fine it captures all messages. I would like now to be able to get the mouse event messages into some readable information ! Any Idea on how to proceed ? They are...
3
2693
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 PopupWindow mUserPopWin; i create a new instance of the popupwin and provide necessary vars. this.mUserPopWin = new PopupWindow(); this.mUserPopWin.UserName = this.List.Name;
0
3163
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 clicking on the PictureBox objects will get that scrolling working. However, after I click on outside of the PictureBox object, then click as many times as I like on the PictureBox the scrolling with the mouse wheel continues to work. I found...
0
1840
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. This will create a new tab, put a new instance of the proper UserControl into the tab, and populate said UserControl with the data culled from the drop source. Because of the nature of this application, the particular UserControl that will be...
4
2009
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 mouse leaves it. The problem is, when the mouse passes in a contained control, the UserControl raises a MouseLeave and the border is restored back, although the mouse, for the customer, is yet inside the UserControl.
0
2418
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 order to be able to move that Form around with the mouse I have to implement EventHandlers for the MouseDown, MouseUp and MouseMove event. Now the problem I have is these Events will never be fired because the entire dialog is covered by the...
2
2359
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 process in a MouseDown event but while the mouse button (left) is pressed my UserControl does not get any MouseMove (or any other mouse) event. What event is triggered when a mouse is moved over a control while a button is pressed? Thanks for any...
3
2694
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 change multiple boxes with a click and drag. On mouse down I toggle the value of the current box and then set two static variables for the class: ButtonDown = true; Activate = (true or false, depending upon which action was just taken.) The...
0
8603
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9157
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9026
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8893
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7723
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.