Thursday, January 14, 2010

Get Mouse Cursor Position Inside or Outside Form

Here is a simple way to get mouse cursor position on the form or outside the form. First create a new form, then add the label and the timer control on the form. After that, paste the following code:

Private Declare Function GetCursorPos Lib "user32" (lpPoint As _
POINTAPI) As Long

Private Type POINTAPI
x As Long
y As Long
End Type
Dim a As POINTAPI
Dim b As Long
Dim c As Long

Private Sub Form_Load()
Timer1.Interval = 1
End Sub

Private Sub Timer1_Timer()
mousepos
End Sub

Private Sub mousepos()
ret = GetCursorPos(a)
b = a.x
c = a.y
Label1.Caption = b
Label2.Caption = c
End Sub


4 comments:

  1. Hi, I'm having a problem with my project, it's a program to manage a Video Rental Service. Could i send it to you, you take a look?

    ReplyDelete
  2. yup..please send your project to my email

    ReplyDelete
  3. aslmkm sir, im having problem with my vb project,it's an inventory system.i have a problem with it such as how to make a calculation,auto increment id, can u help me to solve this problem??

    ReplyDelete
  4. Namaskar! I'm Molay.I've a problem with my problem with my project obout type-mismatch. Actually I want to know the reason for which it takes place & how to fix it. If you kindly send me the solution for this problem ,it will help me very much.Plz... help me![My email-id is molaydas7@gmail.com]

    ReplyDelete