⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 VB源码,是初学者的福因.让你很快掌握VB编程
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   4185
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   4680
   LinkTopic       =   "Form1"
   ScaleHeight     =   4185
   ScaleWidth      =   4680
   StartUpPosition =   3  '窗口缺省
   Begin VB.FileListBox File1 
      Height          =   1350
      Left            =   360
      TabIndex        =   4
      Top             =   1560
      Width           =   1455
   End
   Begin VB.DirListBox Dir1 
      Height          =   930
      Left            =   360
      TabIndex        =   3
      Top             =   480
      Width           =   1455
   End
   Begin VB.DriveListBox Drive1 
      Height          =   300
      Left            =   360
      TabIndex        =   2
      Top             =   120
      Width           =   1455
   End
   Begin VB.CommandButton cmdStop 
      Caption         =   "Command2"
      Height          =   735
      Left            =   2160
      TabIndex        =   1
      Top             =   1080
      Width           =   1815
   End
   Begin VB.CommandButton cmdPlay 
      Caption         =   "Command1"
      Height          =   735
      Left            =   2160
      TabIndex        =   0
      Top             =   120
      Width           =   1815
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Form_Load()
    Dim errcode As Long  ' MCI错误代码
    cmdPlay.Caption = "播放canyou.mid文件"
    cmdStop.Caption = "停止播放"
    errcode = mciSendString("open canyon.mid alias canyon", _
                 "", 0, 0)
    If errcode <> 0 Then DisplayError errcode
End Sub

Private Sub Drive1_Change()
    Dir1.Path = Drive1.Drive
End Sub

Private Sub Dir1_Change()
    File1.Path = Dir1.Path
End Sub

Private Sub cmdPlay_Click()
    ' 在按下按钮时播放该MIDI文件
    Dim errcode As Long  ' MCI错误代码
    errcode = mciSendString("play canyon", "", 0, 0)
    If errcode <> 0 Then DisplayError errcode
End Sub

Private Sub cmdStop_Click()
    ' 在按下按钮时停止播放,文件中的位置不会复位到开始
    Dim errcode As Long  ' MCI错误代码
    errcode = mciSendString("stop canyon", "", 0, 0)
    If errcode <> 0 Then DisplayError errcode
End Sub

Private Sub Form_Unload(Cancel As Integer)
    '  在窗体卸载时关闭MIDI文件,因为MIDI驱动程序每次只能处理一个文件
    Dim errcode As Long  ' MCI error code
    errcode = mciSendString("close canyon", "", 0, 0)
End Sub

Private Sub DisplayError(ByVal errcode As Long)
    ' 显示MCI错误的对话框
    Dim errstr As String  ' MCI错误信息文本
    Dim retval As Long    ' 返回值
    ' 获取解释MCI错误的字符串
    errstr = Space(128)
    retval = mciGetErrorString(errcode, errstr, Len(errstr))
    ' 清除尾部的空字符
    errstr = Left(errstr, InStr(errstr, vbNullChar) - 1)
    ' 显示简单错误消息框
    retval = MsgBox(errstr, vbOKOnly Or vbCritical)
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -