467,903 Members | 1,782 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

need help finding cursor coordinates ?

aam
Hi. I am trying to find the cursor coordinates inside of a window, not a
form. I would like to display the coordinates of the cursor when you click
inside of the window. Either that, or have the current coordinates of the
cursor displayed as you are moving it around inside of the window. Thanks for
any help with this.
Nov 21 '05 #1
  • viewed: 1431
Share:
3 Replies
This is what I done:

1) Start a new Windows application

2) Add a timer (Timer1) to the project, enable it & set it to 100

3) Double-click the timer & paste this in:

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
Dim intX As Integer = Cursor.Position.X
Dim intY As Integer = Cursor.Position.Y
Me.Text = String.Format("X={0}, Y={1}", intX, intY)
End Sub

When you run it, the text of the form will show the coordinates of the
current mouse position

I hope this helps
Nov 21 '05 #2
aam
Thanks, but what i need is to be able to find the coordinates inside of a
window, not screen coordinates.

"Crouchie1998" wrote:
This is what I done:

1) Start a new Windows application

2) Add a timer (Timer1) to the project, enable it & set it to 100

3) Double-click the timer & paste this in:

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
Dim intX As Integer = Cursor.Position.X
Dim intY As Integer = Cursor.Position.Y
Me.Text = String.Format("X={0}, Y={1}", intX, intY)
End Sub

When you run it, the text of the form will show the coordinates of the
current mouse position

I hope this helps

Nov 21 '05 #3
On 2005-03-01, aam <aa*@discussions.microsoft.com> wrote:
Thanks, but what i need is to be able to find the coordinates inside of a
window, not screen coordinates.

"Crouchie1998" wrote:
This is what I done:

1) Start a new Windows application

2) Add a timer (Timer1) to the project, enable it & set it to 100

3) Double-click the timer & paste this in:

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Timer1.Tick
Dim intX As Integer = Cursor.Position.X
Dim intY As Integer = Cursor.Position.Y
Me.Text = String.Format("X={0}, Y={1}", intX, intY)
End Sub

When you run it, the text of the form will show the coordinates of the
current mouse position

I hope this helps


The form has a PointToClient and a PointToScreen method that maybe able
to help you get the point into the correct coordinates...

--
Tom Shelton [MVP]
Nov 21 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Robin Shuff | last post: by
10 posts views Thread by Danny | last post: by
1 post views Thread by Dan H. | last post: by
3 posts views Thread by shorti | last post: by
reply views Thread by =?Utf-8?B?cm9kY2hhcg==?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.