📄 form1.frm
字号:
VERSION 5.00
Object = "{C1A8AF28-1257-101B-8FB0-0020AF039CA3}#1.1#0"; "MCI32.OCX"
Object = "{6B7E6392-850A-101B-AFC0-4210102A8DA7}#1.3#0"; "COMCTL32.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form Form1
Caption = "Form1"
ClientHeight = 1755
ClientLeft = 165
ClientTop = 735
ClientWidth = 4680
LinkTopic = "Form1"
ScaleHeight = 1755
ScaleWidth = 4680
StartUpPosition = 3 '窗口缺省
Begin VB.CheckBox Check1
Caption = "Check1"
Height = 255
Left = 3720
TabIndex = 3
Top = 240
Width = 1215
End
Begin ComctlLib.Slider Slider1
Height = 375
Left = 120
TabIndex = 2
Top = 120
Width = 3615
_ExtentX = 6376
_ExtentY = 661
_Version = 327682
LargeChange = 10
SmallChange = 10
End
Begin ComctlLib.StatusBar StatusBar1
Align = 2 'Align Bottom
Height = 375
Left = 0
TabIndex = 1
Top = 1380
Width = 4680
_ExtentX = 8255
_ExtentY = 661
SimpleText = ""
_Version = 327682
BeginProperty Panels {0713E89E-850A-101B-AFC0-4210102A8DA7}
NumPanels = 5
BeginProperty Panel1 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Object.Width = 1501
MinWidth = 1501
Text = "剩余时间"
TextSave = "剩余时间"
Object.Tag = ""
EndProperty
BeginProperty Panel2 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Object.Width = 1499
MinWidth = 1499
Object.Tag = ""
EndProperty
BeginProperty Panel3 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Object.Width = 1500
MinWidth = 1500
Text = "总时间"
TextSave = "总时间"
Object.Tag = ""
EndProperty
BeginProperty Panel4 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Object.Width = 1499
MinWidth = 1499
Object.Tag = ""
EndProperty
BeginProperty Panel5 {0713E89F-850A-101B-AFC0-4210102A8DA7}
Object.Tag = ""
EndProperty
EndProperty
End
Begin MSComDlg.CommonDialog CommonDialog1
Left = 3960
Top = 840
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin MCI.MMControl MMControl1
Height = 450
Left = 240
TabIndex = 0
Top = 840
Width = 3540
_ExtentX = 6244
_ExtentY = 794
_Version = 393216
DeviceType = ""
FileName = "C:\WINNT\clock.avi"
End
Begin VB.Label Label3
Caption = "Label3"
Height = 375
Left = 3120
TabIndex = 6
Top = 480
Width = 495
End
Begin VB.Label Label2
Caption = "Label2"
Height = 255
Left = 1800
TabIndex = 5
Top = 480
Width = 735
End
Begin VB.Label Label1
Caption = "Label1"
Height = 255
Left = 360
TabIndex = 4
Top = 480
Width = 735
End
Begin VB.Menu mnuFile
Caption = "文件(&F)"
Begin VB.Menu mnuOpen
Caption = "打开(&O)"
End
Begin VB.Menu mnuClose
Caption = "关闭(&C)"
End
Begin VB.Menu mnuExit
Caption = "退出(&E)"
End
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()
Check1.Caption = "重复"
Label1.Caption = ""
Label2.Caption = ""
Label3.Caption = ""
mnuClose.Enabled = False
End Sub
Private Sub MnuOpen_Click()
' 设定打开文件类型
CommonDialog1.Filter = "MIDI音乐序器(*.mid)|*.mid|声音(*.wav)|*.wav" _
& "|Widows视频(*.avi)|*.avi|VCD文件(*.mpg)|*.mpg|所有文件(*.*)|*.*"
CommonDialog1.ShowOpen
MMControl1.Notify = False
MMControl1.Wait = True
MMControl1.Shareable = False
MMControl1.DeviceType = "" '由系统默认设备类型
MMControl1.FileName = CommonDialog1.FileName
MMControl1.Command = "Open" ' 打开 MCI 设备
mnuOpen.Enabled = False
mnuClose.Enabled = True
Slider1.Visible = True
End Sub
Private Sub MMControl1_StatusUpdate()
'设置文件长度以毫秒形式返回,
MMControl1.TimeFormat = 0
Slider1.Max = MMControl1.Length / 1000 + 1
If MMControl1.Position <> MMControl1.Length Then
Slider1.Value = MMControl1.Position / 1000
Else
MMControl1.Command = "Prev"
Slider1.Value = 0
End If
'调用Tstring函数计算剩余时间和总时间
StatusBar1.Panels(2) = Tstring(MMControl1.Length - MMControl1.Position)
StatusBar1.Panels(4) = Tstring(MMControl1.Length)
Label1.Caption = "00:00"
Label2.Caption = Tstring(MMControl1.Length / 2)
Label3.Caption = Tstring(MMControl1.Length)
' 由Mode返回不同值并在状态栏经出相应的提示
Select Case MMControl1.Mode
Case 524
StatusBar1.Panels(5) = " 未打开设备……"
Case 525
StatusBar1.Panels(5) = "停止状态……"
Case 526
StatusBar1.Panels(5) = "正在播放……" & CommonDialog1.FileTitle
Case 527
StatusBar1.Panels(5) = "正在录音……"
Case 528
StatusBar1.Panels(5) = "正在搜索……"
Case 529
StatusBar1.Panels(5) = "暂停播放……"
Case 530
StatusBar1.Panels(5) = "设备就绪……"
End Select
End Sub
' 自定义将毫秒转化为分?秒Tstring函数
Private Function Tstring(sm As Long) As String
s = (sm / 1000 / 60) Mod 60
m = (sm / 1000) Mod 60
Tstring = Format(s, "00") & ";" & Format(m, "00")
End Function
Private Sub MMControl1_Done(NotifyCode As Integer)
MMControl1.UpdateInterval = 100 ' 间隔100毫秒
End Sub
Private Sub MnuClose_Click()
MMControl1.Command = "Close"
mnuClose.Enabled = False
mnuOpen.Enabled = True
Slider1.Value = 0
End Sub
Private Sub MnuExit_Click()
MMControl1.Command = "Close"
End
End Sub
Private Sub Check1_Click()
If Check1.Value = 1 Then
MMControl1.Command = "Play" ' 继续播放
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -