{VB.net}我试图在一个单独的线程中处理TreeView元素的MouseMove事件,但我不知道如何做到这一点并且搜索网络没有太大帮助。
Private Sub TV_ServerList_MouseMove(sender As Object, e As MouseEventArgs) Handles TV_ServerList.MouseMove
Try
selNode = DirectCast(TV_ServerList.GetNodeAt(TV_ServerList.PointToClient(Cursor.Position)), TreeNode)
Dim screenHeight As Integer = Screen.PrimaryScreen.Bounds.Height - 220
If Not oldnode.Name = selNode.Name Then
frm.StartPosition = FormStartPosition.Manual
Dim cursor_x = System.Windows.Forms.Cursor.Position.X - 800
Dim cursor_y = System.Windows.Forms.Cursor.Position.Y - 10
If cursor_y > screenHeight Then
cursor_y = screenHeight
End If
frm.Location = New Point(cursor_x, cursor_y)
Try
frm.change()
Catch ex As Exception
End Try
frm.Show()
oldnode = selNode
ElseIf oldnode.name = "" Then
frm.StartPosition = FormStartPosition.Manual
Dim cursor_x = System.Windows.Forms.Cursor.Position.X - 800
Dim cursor_y = System.Windows.Forms.Cursor.Position.Y - 10
frm.Location = New Point(cursor_x, cursor_y)
Try
frm.change()
Catch ex As Exception
End Try
frm.Show()
oldnode = selNode
Else
frm.StartPosition = FormStartPosition.Manual
Dim cursor_x = System.Windows.Forms.Cursor.Position.X - 800
Dim cursor_y = System.Windows.Forms.Cursor.Position.Y - 10
frm.Location = New Point(cursor_x, cursor_y)
oldnode = selNode
End If
Catch ex As Exception
frm.hide()
End Try
End Sub
我希望将此代码放在一个单独的线程中执行。
从Private Sub TV_ServerList_MouseMove(sender As Object, e As MouseEventArgs) Handles TV_ServerList.MouseMove
内部开始一个新主题
不是一种选择。我希望在Form1加载时从头开始。
请求帮助。