VERSION 5.00
Object = "{27395F88-0C0C-101B-A3C9-08002B2F49FB}#1.1#0"; "PICCLP32.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1 
   Caption         =   "VB6 例10-20  后台音乐"
   ClientHeight    =   4230
   ClientLeft      =   1095
   ClientTop       =   1515
   ClientWidth     =   6720
   LinkTopic       =   "Form1"
   PaletteMode     =   1  'UseZOrder
   ScaleHeight     =   4230
   ScaleWidth      =   6720
   Begin MSComDlg.CommonDialog CommonDialog1 
      Left            =   420
      Top             =   1380
      _ExtentX        =   847
      _ExtentY        =   847
      _Version        =   393216
   End
   Begin VB.CommandButton Command4 
      Caption         =   "停止音乐"
      Height          =   465
      Left            =   5460
      TabIndex        =   3
      Top             =   780
      Width           =   945
   End
   Begin VB.CommandButton Command3 
      Caption         =   "播放音乐"
      Height          =   465
      Left            =   5460
      TabIndex        =   2
      Top             =   180
      Width           =   945
   End
   Begin PicClip.PictureClip PictureClip1 
      Left            =   1860
      Top             =   1680
      _ExtentX        =   3519
      _ExtentY        =   3519
      _Version        =   393216
      Rows            =   4
      Cols            =   4
      Picture         =   "V6bj10-20.frx":0000
   End
   Begin VB.CommandButton Command2 
      Caption         =   "结束"
      Height          =   465
      Left            =   5400
      TabIndex        =   1
      Top             =   3480
      Width           =   945
   End
   Begin VB.CommandButton Command1 
      Caption         =   "开始"
      Height          =   465
      Left            =   5400
      TabIndex        =   0
      Top             =   2880
      Width           =   945
   End
   Begin VB.Timer Timer1 
      Enabled         =   0   'False
      Interval        =   100
      Left            =   825
      Top             =   3300
   End
   Begin VB.Image Image1 
      Height          =   480
      Left            =   420
      Stretch         =   -1  'True
      Top             =   600
      Visible         =   0   'False
      Width           =   480
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim scx As Single, scy As Single
Dim sdx As Single, sdy As Single

Private Sub Command1_Click()
    Image1.Visible = -1      '使图像框可见
    Timer1.Enabled = -1      '时钟控件起作用
End Sub

Private Sub Command2_Click()
    End
End Sub

Private Sub Command3_Click()
    Dim k As Integer
    CommonDialog1.DialogTitle = "选择要装入的声音文件"
    CommonDialog1.Filter = "Wave file(*.wav)|*.wav|All files(*.*)|*.*"
    CommonDialog1.Action = 1
    k = sndPlaySound(CommonDialog1.FileName, &H9)
End Sub

Private Sub Command4_Click()
    Dim k As Integer
    k = sndPlaySound(" ", 0)
End Sub

Private Sub Form_Load()
    scx = 50: scy = 75
    sdx = 50: sdy = 50
End Sub

Private Sub Timer1_Timer()
    Static i As Integer                         ' 设置静态变量索引GraphicCell
    Image1.Picture = PictureClip1.GraphicCell(i)
    i = i + 1
    If i > 15 Then i = 0
    Image1.Move Image1.Left + scx, Image1.Top + scy
    ' 若图像控件到达窗体右边界，改变scx值，使之向左移动
    If Image1.Left + Image1.Width >= ScaleWidth + ScaleLeft Then scx = -50
    ' 若图像控件到达窗体左边界，改变scx值，使之向右移动
    If Image1.Left <= 0 Then scx = 50
    ' 若图像控件到达窗体底边界，改变scy值，使之向上移动
    If Image1.Top + Image1.Height >= ScaleHeight + ScaleTop Then scy = -75
    ' 若图像控件到达窗体顶部边界，改变scy值，使之向下移动
    If Image1.Top <= 0 Then scy = 75
    ' 改变图像控件的大小
    Image1.Height = Image1.Height + sdy
    Image1.Width = Image1.Width + sdx
    If Image1.Height >= 1000 Then sdy = -50
    If Image1.Width >= 1000 Then sdx = -50
    If Image1.Height <= 200 Then sdy = 50
    If Image1.Width <= 200 Then sdx = 50
End Sub

