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

Home Posts Topics Members FAQ

Mouse Movement & Control Bounds

Tom
Hi

I am having problems working out if the mouse pointer is within the
control bounds within the OnMouseMove method:

Protected Overrides Sub OnMouseMove(ByV al e As MouseEventArgs)

Debug.WriteLine (Me.Bounds.Cont ains(e.X, e.Y))

End Sub

This always returns false even when the mouse is being moved over the
control. I would expect it only to return false if the mouse was being
moved outside the control when the mouse button was originally pressed
over the control.

MSDN suggests that i am using it correctly:

http://msdn.microsoft.com/library/de...ainstopic1.asp

Anyone know where i am going wrong?

Thanks

Tom
Nov 20 '05 #1
8 2783
"Tom" <re***@to.group > schrieb
Hi

I am having problems working out if the mouse pointer is within
the control bounds within the OnMouseMove method:

Protected Overrides Sub OnMouseMove(ByV al e As
MouseEventArgs)

Debug.WriteLine (Me.Bounds.Cont ains(e.X, e.Y))

End Sub

This always returns false even when the mouse is being moved over
the control. I would expect it only to return false if the mouse was
being moved outside the control when the mouse button was originally
pressed over the control.

MSDN suggests that i am using it correctly:

http://msdn.microsoft.com/
library/default.asp?url =/library/en-us/cpref/html/frlrfsystemdr
awingrectanglec lasscontai nstopic1.asp

Anyone know where i am going wrong?


Bounds returns coordinates relative to the parent of the control, whereas
e.x and e.y are relative to the top left corner of the control.

Use
Debug.WriteLine (Me.ClientRecta ngle.Contains(e .X, e.Y))

BTW, don't forget to call
MyBase.OnMouseM ove(e)
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
Nov 20 '05 #2
Tom
>On Thu, 20 May 2004 13:21:00 +0200, "Armin Zingler" <az*******@free net.de> wrote:
Bounds returns coordinates relative to the parent of the control, whereas
e.x and e.y are relative to the top left corner of the control.

Use
Debug.WriteLine (Me.ClientRecta ngle.Contains(e .X, e.Y))

BTW, don't forget to call
MyBase.OnMouse Move(e)


Armin, that's fantastic, thanks mate.
Nov 20 '05 #3
* Tom <re***@to.group > scripsit:
I am having problems working out if the mouse pointer is within the
control bounds within the OnMouseMove method:

Protected Overrides Sub OnMouseMove(ByV al e As MouseEventArgs)

Debug.WriteLine (Me.Bounds.Cont ains(e.X, e.Y))

End Sub

This always returns false even when the mouse is being moved over the
control. I would expect it only to return false if the mouse was being


Mouse events will only be generated for the control under the mouse, so
you won't receive an event when the mouse is moved outside the control.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4
Tom
On 20 May 2004 16:16:47 +0200, hi************* **@gmx.at (Herfried K.
Wagner [MVP]) wrote:
* Tom <re***@to.group > scripsit:
I am having problems working out if the mouse pointer is within the
control bounds within the OnMouseMove method:

Protected Overrides Sub OnMouseMove(ByV al e As MouseEventArgs)

Debug.WriteLine (Me.Bounds.Cont ains(e.X, e.Y))

End Sub

This always returns false even when the mouse is being moved over the
control. I would expect it only to return false if the mouse was being


Mouse events will only be generated for the control under the mouse, so
you won't receive an event when the mouse is moved outside the control.


If the mouse button is pressed over the control and remains pressed as
you move off the control, the event will still fire as the mouse
moves, likewise the OnMouseUp event.
Nov 20 '05 #5
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> schrieb
This always returns false even when the mouse is being moved over
the control. I would expect it only to return false if the mouse
was being


Mouse events will only be generated for the control under the mouse,
so you won't receive an event when the mouse is moved outside the
control.

No, it is also received outside as stated in the sentence you quoted only
the first half. ;-)

"I would expect it only to return false if the mouse was being
moved outside the control when the mouse button was originally pressed
over the control."
--
Armin

Nov 20 '05 #6
* Tom <re***@to.group > scripsit:
This always returns false even when the mouse is being moved over the
control. I would expect it only to return false if the mouse was being


Mouse events will only be generated for the control under the mouse, so
you won't receive an event when the mouse is moved outside the control.


If the mouse button is pressed over the control and remains pressed as
you move off the control, the event will still fire as the mouse
moves, likewise the OnMouseUp event.


OK, I didn't think of that. Thank you for making me aware that I missed
this case.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #7
* "Armin Zingler" <az*******@free net.de> scripsit:
No, it is also received outside as stated in the sentence you quoted only
the first half. ;-)

"I would expect it only to return false if the mouse was being
moved outside the control when the mouse button was originally pressed
over the control."


Sorry :-(. I took 13 hours of sleep but I am still tired...

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #8
We see it, however now I know I will have patience

Cor

Sorry :-(. I took 13 hours of sleep but I am still tired...

Nov 20 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
32638
by: BadOmen | last post by:
I want my program to send a mouse click to the window at the current mouse position, how do I do that? Example: I have my mouse over a button in Word and then my program is sending the left mouse click and the button under the mouse is clicked. Yours, Jonas
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
2
2879
by: harrylmh | last post by:
Hi, Here's the problem. Whenever the mouse goes out of the form or any control tat handles mouse move, the mouse stop sending it's coordinates back to the program. How can I correct this? What's needs is an event that is fired whenever the mouse moves or moves outside the bounds form. Thanks in advance
1
19179
by: Benny Raymond | last post by:
In my attempt to make a macro recording program where i can then playback mouse movements i'm running into a big problem: I'm trying to simulate the movement of the mouse to a point on the screen. With my current code the mouse is only moving in the X direction and not in the Y direction (however my debug line is telling me that it's trying to move in the Y as well). I've read everything I could find online, tried some hacky ways of...
5
3717
by: Charles Law | last post by:
Sorry for reposting this question, but I did not get a single answer last time, and I'm sure you guys must have some thoughts on the matter. I have a user control which can be dragged and dropped onto a form in my application when it is running. I allow it to be clicked and dragged to a new location on the form. However, the user control has a check box on it, and if the user clicks over the checkbox to drag the user control, the check...
3
3764
by: Morten Snedker | last post by:
If I have a number of random applications open, move the mouse cursor to a given position and do a click, the application gets the focus. That is what this simple code should illustrate: Dim pt As Point Dim wnd As IntPtr Const WM_LBUTTONUP = &H202 '//LButton up Const WM_LBUTTONDOWN = &H201 '//LButton down
2
3131
by: markszlazak | last post by:
In the following script, a control displays (black box) in each table cell once you mouse over the cell. Mouse down on the control to change the mode of the table. Drag the mouse over cells in the same column then mouseup anywhere in a cell. The mouseup event sometimres fires before the selection of table cells by dragging is complete. It's important that I stop these "false" mouseup's from firing or distinguish them from when I let go of...
5
3393
by: vidishasharma | last post by:
Hi, I have a windows from with few controls over it. Now I have to see if the cursor goes outside the bounds of the windows form then I have to close the form. I added mouse leave for the form however as soon as the cursor goes on any control over the form form_ MouseLeave is fired. I want to this to be fired only if it goes outside the bounds of the
4
6971
by: mike | last post by:
I have the opportunity to rescue a project that uses a mouse to sense the relative position of a machine. The hardware is built...just needs to be programmed. Stop snickering!!! I didn't do it...I just gotta fix it. I need to make some calculations on the measurements and VB6 is my language. Yes, the system mouse will corrupt the measurement, but it's an auditing function and that's acceptable.
0
9032
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
8905
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
8880
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
7743
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
6532
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
4373
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4625
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3053
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2342
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.