الدرس الثالث عشر تشغيل الاصوات
تم الشرح بطريقتين تستعملان الاستدعاء بواسطة الدوال الموجودة بالحاسب الالي
شرح الطريقة الاولى بالصوت و الصورة
الطريقة الثانية بالصوت و الصورة
يرجى ملاحظة:
1- حفظ الملف في مجلد.
2- ادراج الاصوات في نفس المجلدالسابق.
3- التأكد ان الصوت من النوع wave .
استخدام الكود التالي كما هو و تغيير فقط اسم الملف الصوتى.
كود الشرح الاول :
كود:
Private Declare Function PlaySound Lib "winmm.dll" Alias "PlaySoundA" (ByVal lpszName As String, ByVal hModule As Long, ByVal dwFlags As Long) As Long
Private Sub CommandButton1_Click()
PlaySound Application.ActivePresentation.Path & "\no.wav", 0, &H1
End Sub
كود الطريقة الثانية
هذا يوضع في المديول Module1
كود:
Private Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long
Option Explicit
Public Sub PSound(FName As String, Optional gAsync As Boolean = True, Optional gLoop As Boolean = False)
Dim Flag&
If FName = "" Then
sndPlaySound 0&, 0
Else
If gAsync = True Then Flag = Flag Or 1
If gLoop = True Then Flag = Flag Or 8
sndPlaySound FName, Flag
End If
End Sub
و هذا خاص بالازرار
كود:
Private Sub CommandButton1_Click()
PSound Application.ActivePresentation.Path & "\no.wav"
End Sub
Private Sub CommandButton2_Click()
PSound ""
End Sub
Private Sub CommandButton3_Click()
PSound Application.ActivePresentation.Path & "\no.wav", True, True
End Sub
ننتظر تطبيقاتكم