📄 mciwavplayer.vb
字号:
Option Strict Off
Option Explicit On
Friend Class Form1
Inherits System.Windows.Forms.Form
#Region "Windows 窗体设计器生成的代码"
Public Sub New()
MyBase.New()
If m_vb6FormDefInstance Is Nothing Then
If m_InitializingDefInstance Then
m_vb6FormDefInstance = Me
Else
Try
'对于启动窗体,所创建的第一个实例为默认实例。
If System.Reflection.Assembly.GetExecutingAssembly.EntryPoint.DeclaringType Is Me.GetType Then
m_vb6FormDefInstance = Me
End If
Catch
End Try
End If
End If
'此调用是 Windows 窗体设计器所必需的。
InitializeComponent()
End Sub
'窗体重写处置,以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal Disposing As Boolean)
If Disposing Then
If Not components Is Nothing Then
components.Dispose()
End If
End If
MyBase.Dispose(Disposing)
End Sub
Private components As System.ComponentModel.IContainer
'Windows 窗体设计器所必需的
Public ToolTip1 As System.Windows.Forms.ToolTip
Public WithEvents STOP_Renamed As System.Windows.Forms.Button
Public WithEvents Text1 As System.Windows.Forms.TextBox
Public WithEvents PLAY As System.Windows.Forms.Button
Public WithEvents OPEN As System.Windows.Forms.Button
Public WithEvents CMDialog1 As AxMSComDlg.AxCommonDialog
'注意:以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器来修改它。
'不要使用代码编辑器来修改它。
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.components = New System.ComponentModel.Container()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.OPEN = New System.Windows.Forms.Button()
Me.ToolTip1 = New System.Windows.Forms.ToolTip(Me.components)
Me.CMDialog1 = New AxMSComDlg.AxCommonDialog()
Me.STOP_Renamed = New System.Windows.Forms.Button()
Me.PLAY = New System.Windows.Forms.Button()
Me.Text1 = New System.Windows.Forms.TextBox()
CType(Me.CMDialog1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'OPEN
'
Me.OPEN.BackColor = System.Drawing.SystemColors.Control
Me.OPEN.Cursor = System.Windows.Forms.Cursors.Default
Me.OPEN.Location = New System.Drawing.Point(20, 37)
Me.OPEN.Name = "OPEN"
Me.OPEN.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.OPEN.Size = New System.Drawing.Size(84, 29)
Me.OPEN.TabIndex = 0
Me.OPEN.Text = "打开"
'
'CMDialog1
'
Me.CMDialog1.Enabled = True
Me.CMDialog1.Location = New System.Drawing.Point(102, 37)
Me.CMDialog1.Name = "CMDialog1"
Me.CMDialog1.OcxState = CType(resources.GetObject("CMDialog1.OcxState"), System.Windows.Forms.AxHost.State)
Me.CMDialog1.Size = New System.Drawing.Size(32, 32)
Me.CMDialog1.TabIndex = 4
'
'STOP_Renamed
'
Me.STOP_Renamed.BackColor = System.Drawing.SystemColors.Control
Me.STOP_Renamed.Cursor = System.Windows.Forms.Cursors.Default
Me.STOP_Renamed.Location = New System.Drawing.Point(246, 37)
Me.STOP_Renamed.Name = "STOP_Renamed"
Me.STOP_Renamed.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.STOP_Renamed.Size = New System.Drawing.Size(83, 29)
Me.STOP_Renamed.TabIndex = 3
Me.STOP_Renamed.Text = "停止"
'
'PLAY
'
Me.PLAY.BackColor = System.Drawing.SystemColors.Control
Me.PLAY.Cursor = System.Windows.Forms.Cursors.Default
Me.PLAY.Location = New System.Drawing.Point(133, 37)
Me.PLAY.Name = "PLAY"
Me.PLAY.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.PLAY.Size = New System.Drawing.Size(83, 29)
Me.PLAY.TabIndex = 1
Me.PLAY.Text = "播放"
'
'Text1
'
Me.Text1.AcceptsReturn = True
Me.Text1.AutoSize = False
Me.Text1.BackColor = System.Drawing.SystemColors.Window
Me.Text1.Cursor = System.Windows.Forms.Cursors.IBeam
Me.Text1.ForeColor = System.Drawing.SystemColors.WindowText
Me.Text1.Location = New System.Drawing.Point(20, 9)
Me.Text1.MaxLength = 0
Me.Text1.Name = "Text1"
Me.Text1.RightToLeft = System.Windows.Forms.RightToLeft.No
Me.Text1.Size = New System.Drawing.Size(309, 21)
Me.Text1.TabIndex = 2
Me.Text1.Text = "Text1"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(340, 75)
Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.STOP_Renamed, Me.Text1, Me.PLAY, Me.OPEN, Me.CMDialog1})
Me.Location = New System.Drawing.Point(4, 29)
Me.MaximizeBox = False
Me.Name = "Form1"
Me.Text = "MciExecuteWavePlayer"
CType(Me.CMDialog1, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)
End Sub
#End Region
#Region "升级支持"
Private Shared m_vb6FormDefInstance As Form1
Private Shared m_InitializingDefInstance As Boolean
Public Shared Property DefInstance() As Form1
Get
If m_vb6FormDefInstance Is Nothing OrElse m_vb6FormDefInstance.IsDisposed Then
m_InitializingDefInstance = True
m_vb6FormDefInstance = New Form1()
m_InitializingDefInstance = False
End If
DefInstance = m_vb6FormDefInstance
End Get
Set
m_vb6FormDefInstance = Value
End Set
End Property
#End Region
Public Declare Function mciExecute Lib "winmm.dll" (ByVal lpstrCommand As String) As Integer
Public FileName As String
Dim x As Integer
Private Sub Form1_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
'aFlag = 1
End Sub
Private Sub OPEN_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles OPEN.Click
Dim temp As Object
CMDialog1.FileName = ""
CMDialog1.Flags = MSComDlg.FileOpenConstants.cdlOFNNoReadOnlyReturn
CMDialog1.Filter = "(*.wav)|*.wav|(*.mid)|*.mid|(*.dat)|*.dat|(*.avi)|*.avi|所有文件|*.*"
CMDialog1.FilterIndex = 1 '初始的文件过滤方式为*.avi
CMDialog1.DialogTitle = "打开媒体文件"
CMDialog1.Action = 1
If CMDialog1.FileName = "" Then
'UPGRADE_WARNING: 未能解析对象 temp 的默认属性。 单击以获得更多信息:ms-help://MS.MSDNVS/vbcon/html/vbup1037.htm
temp = MsgBox("没有文件被打开", 37, "检查")
Exit Sub
Else
FileName = CMDialog1.FileName
Text1.Text = FileName
End If
End Sub
Private Sub PLAY_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles PLAY.Click
x = mciExecute("play " & FileName)
End Sub
Private Sub STOP_Renamed_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles STOP_Renamed.Click
x = mciExecute("stop " & FileName)
End
End Sub
End Class
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -