永发信息网

如何应用VB的Picturebox画三角形,多边形

答案:3  悬赏:80  手机版
解决时间 2021-01-29 07:56
  • 提问者网友:蓝莓格格巫
  • 2021-01-29 01:17
用鼠标控制,进行选点
最佳答案
  • 五星知识达人网友:平生事
  • 2021-01-29 02:35
用PictureBox.Line方法就可以画直线了。直线的起点终点由PictureBox的MouseDown事件获取,就可以绘制任意多边形了。
全部回答
  • 1楼网友:独钓一江月
  • 2021-01-29 05:41
是不是要这种形式的? 画一个picture1,在picture1里再画一条line1(控件) Dim X0 As Integer, Y0 As Integer Dim flag As Boolean Private Sub Form_Load() Line1.Visible = False Picture1.AutoRedraw = True Line1.BorderColor = vbRed End Sub Private Sub Picture1_DblClick() '双击清除 Picture1.Cls End Sub Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then flag = True X0 = X: Y0 = Y Line1.X1 = X Line1.Y1 = Y End If End Sub Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If flag = True Then Line1.Visible = True Line1.X2 = X Line1.Y2 = Y End If End Sub Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then flag = False Line1.Visible = False Picture1.Line (X0, Y0)-(X, Y), vbRed End If End Sub
  • 2楼网友:妄饮晩冬酒
  • 2021-01-29 04:09
Dim X0 As Integer, Y0 As Integer Dim flag As Boolean Private Sub Form_Load() Line1.Visible = False Picture1.AutoRedraw = True Line1.BorderColor = vbRed End Sub Private Sub Picture1_DblClick() 双击清除 Picture1.Cls End Sub Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then flag = True X0 = X: Y0 = Y Line1.X1 = X Line1.Y1 = Y End If End Sub Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If flag = True Then Line1.Visible = True Line1.X2 = X Line1.Y2 = Y End If End Sub 后面的我懒得写了自己慢慢算吧。 再看看别人怎么说的。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯