Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
Try
Label1.Text = ""
Label1.Text = Cursor.Position.ToString & vbCrLf
Hwnd = WindowFromPoint(Cursor.Position.X, Cursor.Position.Y)
If Not Hwnd = OldHwnd Then
Dim ClassName As String
Dim x As Int32
ClassName = Space(MAX_PATH)
x = GetClassName(Hwnd, ClassName, MAX_PATH)
If x > 0 Then
ClassName = ClassName.Substring(0, InStr(ClassName, Chr(0)) - 1)
If ClassName.Length > 0 And ClassName = "SysListView32" Then
Label1.Text &= "Classname: " & ClassName & vbCrLf
Else
Exit Sub
End If
Else
Exit Sub
End If
Dim pHwnd As Int32
pHwnd = GetParent(Hwnd)
If pHwnd > 0 Then
Label1.Text &= "pHwnd: " & pHwnd.ToString & vbCrLf
Dim pClassName As String
pClassName = Space(MAX_PATH)
x = GetClassName(pHwnd, pClassName, MAX_PATH)
If x > 0 Then
pClassName = pClassName.Substring(0, InStr(pClassName, Chr(0)) - 1)
If pClassName.Length > 0 And (pClassName = "CtrlNotifySink" Or pClassName = "SHELLDLL_DefView") Then
Label1.Text &= "pClassName: " & pClassName & vbCrLf
Else
Exit Sub
End If
Dim item As HITTESTINFO
Dim p As POINTAPI
item.iSubItem = 0
item.iItem = 0
p.x = Cursor.Position.X
p.y = Cursor.Position.Y
ScreenToClient(Hwnd, p)
item.pt.x = p.x
item.pt.y = p.y
item.flags = LVHT_ONITEM
x = SendMessage(Hwnd, LVM_HITTEST, 0, item)
Label1.Text &= "x: " & x.ToString & " item: " & item.iItem & vbCrLf
Else
Exit Sub
End If
Else
Exit Sub
End If
End If
Catch ex As Exception
MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly)
End Try
End Sub