VB在两个图形中间连接一条直线比如我现在有两个圆形素材,让后点击其中一个素材后会出现一条直线,直线的

发布时间:2021-02-25 08:12:00

VB在两个图形中间连接一条直线比如我现在有两个圆形素材,让后点击其中一个素材后会出现一条直线,直线的一端在这个素材上,另一端会跟着我的鼠标移动,并且可以让它可以连接在第二个素材上.请问该怎么实现?

网友回答

Dim p As Boolean
Private Sub Form_Load()
Line1.Visible = False
End Sub
Private Sub Form_MouseDown(Button As Integer,Shift As Integer,X As Single,Y As Single)
If Not p Then
Line1.X1 = X
Line1.Y1 = Y
Line1.Visible = True
End IfLine1.X2 = X
Line1.Y2 = Y
p = Not p
End Sub
Private Sub Form_MouseMove(Button As Integer,Shift As Integer,X As Single,Y As Single)
If p Then
Line1.X2 = X
Line1.Y2 = Y
End IfEnd Sub
以上代码需要用到一个Line控件Line1
以上问题属网友观点,不代表本站立场,仅供参考!