need help finding cursor coordinates ?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 
Thanks, but what i need is to be able to find the coordinates inside of a
window, not screen coordinates.
 
Thanks, but what i need is to be able to find the coordinates inside of a
window, not screen coordinates.

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top