PDA

Click to See Complete Forum and Search --> : GetCursorPos Api


Evan
Nov 15th, 1999, 05:08 AM
Hello All,

I need a little hand in helping me to build something using a GetCursorPos Api. What Its gonna do is when the mouse clicks it will Put the cursor in a variable. But when I try to do this it screwed up, and it wont allow me to store the Variable info.

What I tried was this...

Dim IntCurPosNEW as long
IntCurPosNEW = GetCursorPos point

But when It did that it came up with a syntax error..

Anyhelp???

Thankyou much,

Evan

Compwiz
Nov 15th, 1999, 05:13 AM
Type POINTAPI
x As long
y As Long
End Type

Private Sub Command1_Click()
Dim z As POINTAPI
Call GetCursorPos(z)
MsgBox "X = " & z.x & vbCrLf & "Y = " & z.y
End Sub

That code is untested.

------------------
Tom Young, 14 Year Old
tyoung@stny.rr.com
ICQ: 15743470 (http://wwp.icq.com/15743470) Add Me (http://wwp.icq.com/scripts/search.dll?to=15743470) ICQ Me (http://wwp.icq.com/scripts/contact.dll?msgto=15743470)
AIM: TomY10 (http://www.aol.com/aim/aim30.html)
PERL, JavaScript and VB Programmer

MartinLiss
Nov 15th, 1999, 05:33 AM
take a look at This great site (http://skyscraper.fortunecity.com/transmission/45/api/s/setcursorpos.html) for VB usage examples and explanations.

------------------
Marty

john_murphy
Nov 17th, 1999, 10:20 PM
GetCursorPos Function
Declare Function GetCursorPos Lib "user32.dll" (lpPoint As POINT_TYPE) As Long

GetCursorPos reads the current position of the mouse cursor. The x and y coordinates of the cursor (relative to the screen) are put into the variable passed as lpPoint. The function returns 0 if an error occured or 1 if it is successful.

lpPoint
Receives the x and y coordinates of the mouse cursor.
Example:

' Display the coordinates of the mouse cursor
Dim coord As POINT_TYPE ' receives coordinates of cursor
Dim retval As Long ' return value

retval = GetCursorPos(coord) ' read cursor location
Debug.Print "The mouse is at:"; coord.x; coord.y