如何在picture里画正方形的vb程式
来源:百度知道 编辑:UC知道 时间:2024/05/07 22:52:54
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