如何在picture里画正方形的vb程式

来源:百度知道 编辑:UC知道 时间:2024/05/07 22:52:54
最好是写一个副程式,尽量简单点的哦,还有三角形啊,圆形啊。意思是我开了两个form,form1有picture1,我想在form2有控件按了之后,可以在form1的picture1里画到相应的形状,本来程序开始的时候form1的picture 是画线的,我要做一个类似windows画图工具那个东东啊,请大家帮帮我。(追加50分),谢谢

Option Explicit
Private aX, aY As Integer
Private Sub Form_Load()
Me.AutoRedraw = True
Me.ScaleMode = 3
Shape1.Visible = False
End Sub

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
aX = X
aY = Y
Shape1.Left = aX
Shape1.Top = aY
Shape1.Width = 0
Shape1.Height = 0
Shape1.Visible = True
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 1 Then
If X >= aX Then
Shape1.Width = X - aX
Else
Shape1.Left = X
Shape1.Width = aX - X
End If
If Y >= aY Then
Shape1.Height = Y - aY
Else
Shape1.Top = Y
Shape1.Height = aY - Y
End If
End If
End Sub

Private