473,387 Members | 1,520 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,387 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 1568
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.