Option Explicit
Private Type POINT X As Long Y As Long End Type
Dim MouseDownFlag As Boolean Dim OldPos As POINT Dim Pos1 As POINT, Pos2 As POINT
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then MouseDownFlag = True Pos1.X = X Pos1.Y = Y End If End Sub
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If MouseDownFlag = True Then Me.Line (Pos1.X, Pos1.Y)-(OldPos.X, OldPos.Y), Me.BackColor Me.Line (Pos1.X, Pos1.Y)-(X, Y), Me.ForeColor OldPos.X = X OldPos.Y = Y End If End Sub
Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) If Button = 1 Then Pos2.X = X Pos2.Y = Y Call DrawCircle(Pos1, Pos2) End If MouseDownFlag = False End Sub
Private Sub DrawCircle(Pos1 As POINT, Pos2 As POINT) Me.Circle (Pos2.X, Pos2.Y), ((Pos1.X - Pos2.X) * (Pos1.X - Pos2.X) + (Pos1.Y - Pos2.Y) * (Pos1.Y - Pos2.Y)) ^ 0.5 End Sub