VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "VB6 例10-18  源图"
   ClientHeight    =   3540
   ClientLeft      =   1110
   ClientTop       =   1350
   ClientWidth     =   2700
   LinkTopic       =   "Form1"
   ScaleHeight     =   3540
   ScaleWidth      =   2700
   Begin VB.PictureBox Picture1 
      AutoSize        =   -1  'True
      ForeColor       =   &H00FFFFFF&
      Height          =   3375
      Left            =   120
      Picture         =   "V6bj10-18.frx":0000
      ScaleHeight     =   3315
      ScaleWidth      =   2415
      TabIndex        =   0
      Top             =   60
      Width           =   2475
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim x1 As Single, y1 As Single, x2 As Single, y2 As Single

Private Sub Form_Load()
    Form2.Show
End Sub

Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    x1 = X: y1 = Y: x2 = X: y2 = Y
    Picture1.DrawMode = 7
    Picture1.DrawStyle = 4                  '线型号为点划线
End Sub
Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 Then                              ' 如果按下鼠标左键
        Picture1.Line (x1, y1)-(x2, y2), , B        ' 擦除原有线框
        x2 = X: y2 = Y                              ' 保存本次新线框右下角坐标
        Picture1.Line (x1, y1)-(x2, y2), , B        ' 画新线框
    End If
End Sub

Private Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    On Error Resume Next
    Form2.Cls
    Picture1.Line (x1, y1)-(x2, y2), , B                ' 擦除原有线框
    Form2.PaintPicture Picture1, x1, y1, x2 - x1, y2 - y1, x1, y1, x2 - x1, y2 - y1
End Sub
