如何制作画图板(用vb) 10
我不知道如何在图片框中按照自己的意愿去画矩形、圆、直线、翻转图形。即产生和Windows中的画图板一样的效果。非常感谢您的回答,但是如何让画图后原来的图形不清除呢?还有如...
我不知道如何在图片框中按照自己的意愿去画矩形、圆、直线、翻转图形。即产生和 Windows中的画图板一样的效果。
非常感谢您的回答,但是如何让画图后原来的图形不清除呢?
还有如何翻转图形? 展开
非常感谢您的回答,但是如何让画图后原来的图形不清除呢?
还有如何翻转图形? 展开
展开全部
建三个command控件,第一个画直线,第二个画矩形,第三个画圆
编写以下代码:
Dim x1 As Integer
Dim y1 As Integer
Dim k As Integer
Private Sub Command1_Click()
k = 1
End Sub
Private Sub Command2_Click()
k = 2
End Sub
Private Sub Command3_Click()
k = 3
End Sub
Private Sub Form_Load()
k = 0
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
x1 = X
y1 = Y
End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If k = 1 And Button = 1 Then
Form1.Cls
Form1.Line (x1, y1)-(X, Y)
ElseIf k = 2 And Button = 1 Then
Form1.Cls
Form1.Line (x1, y1)-(X, Y), , B
ElseIf k = 3 And Button = 1 Then
Form1.Cls
r = Sqr((x1 - X) ^ 2 + (y1 - Y) ^ 2)
Form1.Circle (x1, y1), r
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 And k = 1 Then
Form1.Line (x1, y1)-(X, Y)
k = 0
ElseIf Button = 1 And k = 2 Then
Form1.Line (x1, y1)-(X, Y), , B
k = 0
ElseIf Button = 1 And k = 3 Then
r = Sqr((x1 - X) ^ 2 + (y1 - Y) ^ 2)
Form1.Circle (x1, y1), r
k = 0
End If
End Sub
编写以下代码:
Dim x1 As Integer
Dim y1 As Integer
Dim k As Integer
Private Sub Command1_Click()
k = 1
End Sub
Private Sub Command2_Click()
k = 2
End Sub
Private Sub Command3_Click()
k = 3
End Sub
Private Sub Form_Load()
k = 0
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
x1 = X
y1 = Y
End If
End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If k = 1 And Button = 1 Then
Form1.Cls
Form1.Line (x1, y1)-(X, Y)
ElseIf k = 2 And Button = 1 Then
Form1.Cls
Form1.Line (x1, y1)-(X, Y), , B
ElseIf k = 3 And Button = 1 Then
Form1.Cls
r = Sqr((x1 - X) ^ 2 + (y1 - Y) ^ 2)
Form1.Circle (x1, y1), r
End If
End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 And k = 1 Then
Form1.Line (x1, y1)-(X, Y)
k = 0
ElseIf Button = 1 And k = 2 Then
Form1.Line (x1, y1)-(X, Y), , B
k = 0
ElseIf Button = 1 And k = 3 Then
r = Sqr((x1 - X) ^ 2 + (y1 - Y) ^ 2)
Form1.Circle (x1, y1), r
k = 0
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询