| | |
How can I get Mouse Position?
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
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
- set mouse position (VB.NET)
- 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)
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 |
.net .net2008 2005 2008 access account advanced application array basic beginner browser button buttons center click code combo crystalreport cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic excel exists fade filter forms ftp generatetags html images input insert intel internet listview mobile module monitor net number objects open panel passingparameters pdf picturebox picturebox2 port position print printing problem regex right-to-left save search searchvb.net select serial settings shutdown soap socket sqldatbase sqlserver survey temperature textbox timer timespan transparency trim txttoxmlconverter update user usercontol vb vb.net vb.netformclosing()eventpictureboxmessagebox vba vbnet visual visualbasic.net visualstudio.net visualstudio2008 web winforms wpf wrapingcode xml year






