473,659 Members | 2,886 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1582
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(ByV al sender As System.Object, ByVal e As
System.EventArg s) 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.

"Crouchie19 98" 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(ByV al sender As System.Object, ByVal e As
System.EventArg s) 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*@discussion s.microsoft.com > wrote:
Thanks, but what i need is to be able to find the coordinates inside of a
window, not screen coordinates.

"Crouchie19 98" 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(ByV al sender As System.Object, ByVal e As
System.EventArg s) 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
6936
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 program is running. I've found and have been working with Knowledge Base Article 179192 (http://support.microsoft.com/default.aspx?scid=kb;en-us;179192) which limits the mouse movement to inside a form, but I'd like to adapt this to be limited...
0
1145
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 where you have clicked. I know that when using OnMouseDown event I can get the mouse x and y coordinates, but how could I know where the cursor is in the box? (next to what character) I need to know because I will then have to find the first...
10
18057
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 I've Googled so much my brain hurts. http://www.ghpkendal.co.uk/TestPages/Test.htm Move your cursor over the yellow area and you should see the mouse coordinates echoed above.
1
10113
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 installed a document.onclick event handler which saves the eventX and eventY values, then use those values to set the window top/left coordinates. The problem is that the eventX and eventY values always seem to be the previous coordinates, not the...
9
6216
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
13160
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 to the desktop 2. Retrieve the desktop cursor position. 3. Take the difference of the forms left and top position. Adjust the desktop cursor position based on this.
6
8658
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 the "MouseMove" event for that textbox. Thanks
3
1926
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 time for the same basic query. I will be basically get passed in where I had left off the last call but it is two fields that make up this unique index. The main rule is that I cannot hold open a cursor on the record I last read because it...
0
1066
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 screen it is, is 0,0? thanks, rodchar
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8332
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8525
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6179
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.