473,320 Members | 1,900 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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(ByVal e As MouseEventArgs)

Debug.WriteLine(Me.Bounds.Contains(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 2761
"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(ByVal e As
MouseEventArgs)

Debug.WriteLine(Me.Bounds.Contains(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
awingrectangleclasscontai 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.ClientRectangle.Contains(e.X, e.Y))

BTW, don't forget to call
MyBase.OnMouseMove(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*******@freenet.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.ClientRectangle.Contains(e.X, e.Y))

BTW, don't forget to call
MyBase.OnMouseMove(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(ByVal e As MouseEventArgs)

Debug.WriteLine(Me.Bounds.Contains(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(ByVal e As MouseEventArgs)

Debug.WriteLine(Me.Bounds.Contains(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*******@freenet.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
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...
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...
2
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...
1
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...
5
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...
3
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...
2
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...
5
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...
4
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...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.