HitTest 方法常常与 DropHighlight 属性一起使用来突出鼠标所指的对象。DropHighlight 属性要求对指定要加亮的对象的引用。为了确定那个对象,HitTest 方法与返回 x 和 y 坐标的事件(如 DragOver 事件)一起使用,如下所示:
Private Sub TreeView1_DragOver _
(Source As Control, X As Single, Y As Single, State As Integer)
Set TreeView1.DropHighlight = TreeView1.HitTest(X,Y)
End Sub
Private Sub TreeView1_DragDrop _
(Source As Control, x As Single, y As Single)
'DropHighlight 返回对其上发生放下的对象的引用。
Me.Caption = TreeView1.DropHighlight.Text
'为了释放 DropHighlight 引用,设置它为 Nothing。
Set TreeView1.DropHighlight = Nothing
End Sub
HitTest 方法常常与 DropHighlight 属性一起使用来突出鼠标所指的对象。DropHighlight 属性要求对指定要加亮的对象的引用。为了确定那个对象,HitTest 方法与返回 x 和 y 坐标的事件(如 DragOver 事件)一起使用,如下所示:
Private Sub TreeView1_DragOver _
(Source As Control, X As Single, Y As Single, State As Integer)
Set TreeView1.DropHighlight = TreeView1.HitTest(X,Y)
End Sub
Private Sub TreeView1_DragDrop _
(Source As Control, x As Single, y As Single)
'DropHighlight 返回对其上发生放下的对象的引用。
Me.Caption = TreeView1.DropHighlight.Text
'为了释放 DropHighlight 引用,设置它为 Nothing。
Set TreeView1.DropHighlight = Nothing
End Sub
Private Sub List1_MouseUp(Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = 2 Then
PopupMenu ListSele '假设菜单名为ListSele
End If
End Sub