I'm trying to get hold of basic information about the screen cursor. But the following doesn't work at all. What am I doing wrong?
Code:
Public Class Form1
Private Declare Function GetCursorInfo Lib "user32.dll" (ByVal pc As CURSORINFO) As Long
'Idea to only click when cursor is a hand. Can't get it to work in .net. Works OK in VB6 though.
Structure CURSORINFO
Dim cbsize As Long
Dim flags As Long
Dim hCUrsor As Long
Dim p As Point
End Structure
Structure PointAPI
Dim X As Long
Dim Y As Long
End Structure
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Dim ff As New CURSORINFO
ff.cbsize = System.Runtime.InteropServices.Marshal.SizeOf(GetType(CURSORINFO))
GetCursorInfo(ff)
With ff
'All of the following just show zero.
Label1.Text = .p.X
Label2.Text = .p.Y
Label3.Text = .hCUrsor
End With
End Sub
End Class