form1.frm
来自「本文件包含200个visual baisc实例」· FRM 代码 · 共 265 行
FRM
265 行
VERSION 5.00
Object = "{C1A8AF28-1257-101B-8FB0-0020AF039CA3}#1.1#0"; "MCI32.OCX"
Begin VB.Form form1
Caption = "CD播放器"
ClientHeight = 2145
ClientLeft = 60
ClientTop = 345
ClientWidth = 7140
LinkTopic = "Form1"
ScaleHeight = 2145
ScaleWidth = 7140
StartUpPosition = 1 '所有者中心
Begin VB.CommandButton ComPlay
Caption = "播 放"
Height = 300
Left = 585
TabIndex = 7
Top = 1650
Width = 880
End
Begin VB.CommandButton ComPause
Caption = "暂 停"
Height = 300
Left = 3240
TabIndex = 6
Top = 1650
Width = 880
End
Begin VB.CommandButton ComNext
Caption = "下一个"
Height = 300
Left = 1470
TabIndex = 5
Top = 1650
Width = 880
End
Begin VB.CommandButton ComPrev
Caption = "上一个"
Height = 300
Left = 2355
TabIndex = 4
Top = 1650
Width = 880
End
Begin VB.CommandButton ComStop
Caption = "停 止"
Height = 300
Left = 4110
TabIndex = 3
Top = 1650
Width = 880
End
Begin VB.CommandButton ComEject
Caption = "弹 出"
Height = 300
Left = 4965
TabIndex = 2
Top = 1650
Width = 880
End
Begin VB.CommandButton ComEnd
Caption = "退出"
Height = 300
Left = 5835
TabIndex = 1
Top = 1650
Width = 880
End
Begin MCI.MMControl mci1
Height = 420
Left = 2835
TabIndex = 0
Top = 1125
Width = 3540
_ExtentX = 6244
_ExtentY = 741
_Version = 393216
PrevEnabled = -1 'True
PlayEnabled = -1 'True
PauseEnabled = -1 'True
StepEnabled = -1 'True
StopEnabled = -1 'True
RecordEnabled = -1 'True
Silent = -1 'True
Shareable = -1 'True
DeviceType = ""
FileName = ""
End
Begin VB.Line Line2
BorderColor = &H008080FF&
X1 = 1845
X2 = 5070
Y1 = 630
Y2 = 630
End
Begin VB.Line Line1
BorderColor = &H000000FF&
X1 = 1860
X2 = 5085
Y1 = 585
Y2 = 585
End
Begin VB.Label Label5
BackStyle = 0 'Transparent
Caption = "CD播放器"
BeginProperty Font
Name = "宋体"
Size = 21.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H000000FF&
Height = 555
Left = 2520
TabIndex = 12
Top = 105
Width = 2100
End
Begin VB.Label Label4
BackStyle = 0 'Transparent
Caption = "CD播放器"
BeginProperty Font
Name = "宋体"
Size = 21.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 555
Left = 2505
TabIndex = 11
Top = 135
Width = 2100
End
Begin VB.Label Label3
BackStyle = 0 'Transparent
Caption = "曲目播放总时间: "
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Left = 570
TabIndex = 10
Top = 1260
Width = 3300
End
Begin VB.Label Label2
BackStyle = 0 'Transparent
Caption = "正在播放曲目: "
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Left = 3885
TabIndex = 9
Top = 810
Width = 3375
End
Begin VB.Label Label1
BackStyle = 0 'Transparent
Caption = "曲目: "
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 315
Left = 555
TabIndex = 8
Top = 795
Width = 3300
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()
' 初始化mci设备
mci1.Visible = False
mci1.Notify = True
mci1.Shareable = False
mci1.TimeFormat = 0
mci1.DeviceType = "cdaudio"
mci1.Command = "Open"
mci1.UpdateInterval = 1000
Label1.Caption = "曲目总数:" & mci1.Tracks
Label2.Caption = "正在播放曲目: 0 "
End Sub
Private Sub mci1_StatusUpdate()
Label1.Caption = "曲目总数:" & mci1.Tracks
Label2.Caption = "正在播放曲目:" & Str$(mci1.Track)
Label3.Caption = "曲目播放总时间:" & Trim(Str(Int(mci1.Length / 60000))) + "分"
End Sub
Private Sub ComPlay_Click() '开始播放
mci1.Command = "Play"
ComPause.Enabled = True
ComPlay.Enabled = False
ComStop.Enabled = True
End Sub
Private Sub ComNext_Click() '播放下一首
mci1.Command = "next"
End Sub
Private Sub ComPrev_Click()
mci1.Command = "Prev"
End Sub
Private Sub ComPause_Click() '暂停播放
ComPlay.Enabled = True
mci1.Command = "Pause"
ComPause.Enabled = False
End Sub
Private Sub ComStop_Click() '停止播放
mci1.Command = "Stop"
ComStop.Enabled = False
ComPlay.Enabled = True
End Sub
Private Sub ComEject_Click() '弹出
mci1.Command = "stop"
mci1.Command = "eject"
ComPlay.Enabled = True
End Sub
Private Sub ComEnd_Click() '关闭MCI设备并退出
mci1.Command = "Stop"
mci1.Command = "Close"
End
End Sub
Private Sub Form_Unload(Cancel As Integer) '关闭MCI设备
mci1.Command = "Stop"
mci1.Command = "Close"
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?