vb 做出图画中的画直线的效果7
发布网友
发布时间:2023-09-27 03:47
我来回答
共4个回答
热心网友
时间:2024-05-31 21:26
在窗体上加入控件line1,然后复制下面代码,运行后在窗体上拖放鼠标即可。
Option Explicit
Private Sub Form_Load()
Me.AutoRedraw = True
Line1.Visible = False
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
With Line1
.X1 = X
.Y1 = Y
.X2 = X
.Y2 = Y
.Visible = True
End With
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
With Line1
If Button = 1 Then
.X2 = X
.Y2 = Y
End If
End With
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
With Line1
If Button = 1 Then
.Visible = False
Line (.X1, .Y1)-(.X2, .Y2)
End If
End With
End Sub
热心网友
时间:2024-05-31 21:26
vb有一个shape控件可以做一条直线出来,判断鼠标按下时显示这条直线,同时固定一端(X1和Y1),鼠标移动时修改这条直线的另一端的(X2和Y2),然后在鼠标松开时用Line(X1,Y1)-(X2,Y2)画线并隐藏直线控件就可以了
热心网友
时间:2024-05-31 21:27
line (0,100)-(100,200)
热心网友
时间:2024-05-31 21:27
可以实现而且无须api