怎么在VB中播放音效
怎么在VB中播放音效?比如按下一个按钮的时候播放一小段音频还有··怎么把一个窗体弄成半透明或者完全透明?请给个详细代码...
怎么在VB中播放音效? 比如按下一个按钮的时候播放一小段音频 还有··怎么把一个窗体弄成半透明 或者完全透明?请给个详细代码
展开
展开全部
'//透明代码 '//模块。也可以写成private窗体级函数 '//上边为api函数。下边几个是常量 Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long) As Long Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Public Declare Function SetLayeredWindowAttributes Lib "user32" (ByVal hwnd As Long, ByVal crKey As Long, ByVal bAlpha As Byte, ByVal dwFlags As Long) As Long Public Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Public Const GWL_EXSTYLE = (-20) Public Const WS_EX_LAYERED = &H80000 Public Const LWA_ALPHA = &H2 '//窗体 Private Sub Form_Load() Dim rtn As Long rtn = GetWindowLong(hwnd, GWL_EXSTYLE) rtn = rtn Or WS_EX_LAYERED SetWindowLong hwnd, GWL_EXSTYLE, rtn SetLayeredWindowAttributes hwnd, 0, 150, LWA_ALPHA '//150为透明度。越小透明度越大。0-255 End Sub '****下边为播放音效。说白了不用的格式所用的api不一样。api里边可以用过的有wav mp3.好像mid。其他就不知道了。有些是不可以直接调用。要解码。比如视频 '//直接放模块中。根据过程来调用。如点击按钮command1播放 Private sub Command1_click () 音乐'//这样就可以了。音乐是1.mp3 目录是在当前app.path和程序同一个目录。。要更换改一下即可。 End Sub 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 Public Sub 音乐() Dim Res As Integer, Ret As String * 1024 If blnBaojing = False Then Exit Sub 'Res = mciSendString("play " & APP.PATH & "Shili.wav from 3000 to 8000", Ret, 1024, 0) Res = mciSendString("play " & APP.PATH & "1.mp3", Ret, 1024, 0) '整首播放 End Sub Public Sub 停止播放() Dim Res As Integer, Ret As String * 1024 Res = mciSendString("STOP " & APP.PATH & "1.mp3", Ret, 1024, 0) Res = mciSendString("close all", Ret, 1024, 0) End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |