主题:[讨论]求教 背景声音停不下来
有两个窗体 窗体2有一按钮,代码如下
Private Sub Command1_Click()
Form1.Show
Me.Hide
End Sub
窗体1有一MMControl1控件,代码如下
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 32 Then
MMControl1.FileName = App.Path & "\click.WAV"
MMControl1.Command = "open"
MMControl1.Command = "play"
Sleep 200 '表示延时0.2秒,
MMControl1.Command = "close"
End If
If KeyAscii = 27 Then
If MsgBox("真的要退出吗?", vbYesNo) = vbYes Then
Form2.Show
Unload Me
End If
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
MMControl1.Command = "Close"
End Sub
Private Sub Form_load()
MMControl1.FileName = App.Path & "\flourish.mid"
MMControl1.Command = "open"
MMControl1.Command = "play"
End Sub
现在的问题是,只要在form1中按了空格键(KeyAscii = 32 ),再ESC回到form2,背景音乐就停不下来.......怎样才能回到form2时让背景音乐停止呢?
Private Sub Command1_Click()
Form1.Show
Me.Hide
End Sub
窗体1有一MMControl1控件,代码如下
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Private Sub Form_KeyPress(KeyAscii As Integer)
If KeyAscii = 32 Then
MMControl1.FileName = App.Path & "\click.WAV"
MMControl1.Command = "open"
MMControl1.Command = "play"
Sleep 200 '表示延时0.2秒,
MMControl1.Command = "close"
End If
If KeyAscii = 27 Then
If MsgBox("真的要退出吗?", vbYesNo) = vbYes Then
Form2.Show
Unload Me
End If
End If
End Sub
Private Sub Form_Unload(Cancel As Integer)
MMControl1.Command = "Close"
End Sub
Private Sub Form_load()
MMControl1.FileName = App.Path & "\flourish.mid"
MMControl1.Command = "open"
MMControl1.Command = "play"
End Sub
现在的问题是,只要在form1中按了空格键(KeyAscii = 32 ),再ESC回到form2,背景音乐就停不下来.......怎样才能回到form2时让背景音乐停止呢?