如何制作画图板(用vb)

来源:百度知道 编辑:UC知道 时间:2024/06/02 00:42:06
我不知道如何在图片框中按照自己的意愿去画矩形、圆、直线、翻转图形。即产生和 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(