VBGood网站全文搜索 Google

搜索VBGood全站网页(全文搜索)
首页 - 经验之谈 - 播放背景音乐
发表评论(0)作者:不详, 平台:VB6.0+Win98, 阅读:10117, 日期:2001-06-14
播放背景音乐

  实现步骤:

  1.建立一个新项目,将其命名为Demo6.vbp。

  2.增加模块Demo6.bas,在Demo6.bas中加入如下代码:

Public Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long


  3.在窗体的Form_load的处理程序中加入如下代码:

Private Sub Form_Load()
Dim back
back = mciSendString&("OPEN " + App.Path + "\TEST.MID" + " TYPE
SEQUENCER ALIAS NN", 0&, 0, 0)
back = mciSendString&("PLAY NN FROM 0", 0&, 0, 0)
R% = mciSendString&("CLOSE ANIMATION", 0&, 0, 0)
End Sub


  4.在窗体的Command1_Click的处理程序中加入代码:

Private Sub Command1_Click()
Dim back
back = mciSendString&("CLOSE NN", 0, 0, 0)
End Sub


  5.在窗体的Command2_Click的处理程序中加入代码:

Private Sub Command2_Click()
Dim back
back = mciSendString&("OPEN " + App.Path + "\TEST.MID" + " TYPE
SEQUENCER ALIAS NN", 0&, 0, 0)
back = mciSendString&("PLAY NN FROM 0", 0&, 0, 0)
R% = mciSendString&("CLOSE ANIMATION", 0&, 0, 0)
End Sub