472,791 Members | 1,039 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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
3 1547
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Robin Shuff | last post by:
Hi, I'm trying to limit the movement of the mouse cursor in using a VB app. The idea is to stop the cursor straying on to the second monitor of a dual screen set-up (i.e. a projector) while this...
0
by: Pierre | last post by:
Hi, I am building a user control and I am trying to simulate the behavior of the DateTimePicker control. With DateTimePicker, when you click on it the day or month or year is selected depending on...
10
by: Danny | last post by:
How can I get the coordinates of the mouse cursor in Mozilla browsers as well as Opera and IE6? I'm struggling to understand how to capture mouse movement events with Mozilla/Netscape/Firefox and...
1
by: Dave Hammond | last post by:
I have an html element (a link) with an onclick handler which opens a popup window, and would like to position that window at the coordinates where the element appears on the page. I have...
9
by: glin | last post by:
Hi Guys, I am having problem finding the position of a button that I can set the div position next to the button. Can you please help? Thanks in advance.
1
by: Dan H. | last post by:
Hello, I want to try to retrieve the cursor position x and y relative to the form the cursor is over. The way I am doing it now is: 1. Retrieve the left and top position of the form relative...
6
by: Andrea V.F. | last post by:
How can I determine the control under the mouse cursor when a user muves the mouse?? For example if the user moves the cursor over a textbox i would receive the name of that textbox without using...
3
by: shorti | last post by:
db2 v 8.2 on AIX 5.3 I will try to explain as brief as I can what it is I need. I am building a function that will be called multiple times where I will need to return x amount of records each...
0
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i'm using a mouseover event for my div and i was wondering how to get the coordinates of the cursor relative to my DIV. For instance the top left corner of my div, no matter where on the...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.