| | |
How can I get Mouse Position?
Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
Join Date: Oct 2004
Posts: 2
Reputation:
Solved Threads: 0
•
•
•
•
Originally Posted by vbpro
How can I get the Mouse Position from the mousemove event inthe VB.net?
I can't find out how to do this.. :rolleyes:
VB.NET Syntax (Toggle Plain Text)
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove Label1.Text = "X." & e.X & vbCrLf & "Y." & e.Y End Sub
•
•
Join Date: Jul 2007
Posts: 1
Reputation:
Solved Threads: 0
•
•
•
•
VB.NET Syntax (Toggle Plain Text)
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseMove Label1.Text = "X." & e.X & vbCrLf & "Y." & e.Y End Sub
but these code above only works inside the form.
how to get the mouse coordinates / position by using VB2005.NET in anywhere?
you cant get the coordinates of the pointer outside the form..
if you wish to.. customize windows!! :lol:
if you wish to.. customize windows!! :lol:
VB.NET Syntax (Toggle Plain Text)
Dim MyPointAPI As POINTAPI Private Type POINTAPI X As Long Y As Long End Type Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long Public Sub Timer1_Timer() l = GetCursorPos(MyPointAPI) Label1.Caption = CStr(MyPointAPI.X) & ", " & CStr(MyPointAPI.Y) End Sub
Last edited by Skullmagic; Jul 25th, 2007 at 5:38 am. Reason: Don't look good!!!
•
•
Join Date: Jul 2007
Posts: 24
Reputation:
Solved Threads: 0
I have not been using VB for very long but this is how I have been getting the mouse postion on the screen.
I hope this helps
VB.NET Syntax (Toggle Plain Text)
Dim MousePosition As Point MousePosition = Cursor.Position
I hope this helps
•
•
Join Date: Feb 2009
Posts: 2
Reputation:
Solved Threads: 0
I know this thread is old, but I'm confused as to why so many people think this impossible, at least without using an API.
blondie.simon was on the right tracks.
Here's how:
Simples see!
And to capture the location when the mouse is moving:
Note, that the above only functions when the mouse is not over any other form object, but the form itself. It is possible to only capture the mouse movement within a single object too, like a label or picture box for example.
blondie.simon was on the right tracks.
Here's how:
VB.NET Syntax (Toggle Plain Text)
dim mousePos as point = me.mouseposition dim mousePosX as integer = form1.mouseposition.x dim mousePosY as integer = form1.mouseposition.y
Simples see!
And to capture the location when the mouse is moving:
VB.NET Syntax (Toggle Plain Text)
Private Sub mouseMove_Capture(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles _ MyBase.MouseMove Dim mousePos As point= Me.MousePosition End Sub
![]() |
Similar Threads
- Tkinter set mouse position? (Python)
- mouse position (Java)
- finding mouse position relative to my window (C++)
- Convert mouse position to Texture position on ball (Game Development)
- set mouse position (VB.NET)
Other Threads in the VB.NET Forum
- Previous Thread: Problem with VB 2008 program
- Next Thread: RichTextBox SpellCheck with GetSpellingError
| Thread Tools | Search this Thread |
"crystal .net .net2005 30minutes 2005 2008 access account arithmetic array assignment basic box button buttons center check code component connectionstring convert crystalreport data database databasesearch datagrid datagridview date design dissertation dissertations dissertationthesis dosconsolevb.net dropdownlist excel fade file-dialog firewall folder ftp generatetags hardcopy image images input insert intel isnumericfuntioncall math monitor ms navigate net networking opacity output passingparameters peertopeervideostreaming picturebox picturebox1 port problem problemwithinstallation project reports" savedialog searchvb.net select serial shutdown string survey tcp temp temperature text textbox timer toolbox trim updown user useraccounts usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb.nettoolboxvisualbasic2008sidebar vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio2008 web winforms wpf






