VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   5760
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   8940
   LinkTopic       =   "Form1"
   ScaleHeight     =   5760
   ScaleWidth      =   8940
   StartUpPosition =   3  'Windows Default
   Begin VB.PictureBox Picture1 
      Height          =   5775
      Left            =   120
      ScaleHeight     =   5715
      ScaleWidth      =   8835
      TabIndex        =   0
      Top             =   0
      Width           =   8895
      Begin VB.CommandButton Command1 
         Caption         =   "Command1"
         Height          =   375
         Left            =   720
         TabIndex        =   1
         Top             =   360
         Width           =   1335
      End
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Option Explicit

Private m_InDrawMode As Boolean
Private m_ActivateDrawmode As Boolean
Private m_myLine As Line

Private Sub Command1_Click()

    m_ActivateDrawmode = True

End Sub

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    
    Static LineNumber As Long

    If m_ActivateDrawmode Then
        'create a new line and initialise it at the current mouse pointer
        LineNumber = LineNumber + 1
        
         Set m_myLine = Me.Controls.Add("VB.Line", "Line" & CStr(LineNumber), Picture1)

        m_myLine.X1 = X
        m_myLine.X2 = X
        m_myLine.Y1 = Y
        m_myLine.Y2 = Y
        m_myLine.Visible = True
        m_InDrawMode = True
    End If
End Sub

Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If m_InDrawMode Then
        'move the end point of the line
        m_myLine.X2 = X
        m_myLine.Y2 = Y
    End If
End Sub

Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    m_InDrawMode = False
    m_ActivateDrawmode = False
End Sub

