Option Explicit
Private Type 坐标类型
X As Integer
Y As Integer
End Type
Dim A As 坐标类型
Dim B As 坐标类型
Dim MD As Integer
'MD ,鼠标状态
'=0 ,无操作,1=拖动A,2=拖动B
Private Sub Form_Load()
MD = 0
A.X = 500
A.Y = 500
B.X = 2000
B.Y = 2000
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
If Abs(X - A.X) < 75 And Abs(Y - A.Y) < 75 Then
MD = 1
Me.MousePointer = vbSizeAll
ElseIf Abs(X - B.X) < 75 And Abs(Y - B.Y) < 75 Then
MD = 2
Me.MousePointer = vbSizeAll
Else
Me.MousePointer = vbDefault
End If
Else
Me.MousePointer = vbDefault
End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If MD = 1 Then
A.X = X
A.Y = Y
Call Form_Paint
ElseIf MD = 2 Then
B.X = X
B.Y = Y
Call Form_Paint
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MD = 0
Me.MousePointer = vbDefault
End Sub
Private Sub Form_Paint()
With Me
.Cls
Me.Line (A.X, 0)-(A.X, A.Y)
Me.Line (0, A.Y)-(A.X, A.Y)
Me.Line (B.X, Me.ScaleHeight)-(B.X, B.Y)
Me.Line (Me.ScaleWidth, B.Y)-(B.X, B.Y)
End With
End Sub