Author Message

Hi all,
  I just want to make sure I'm doing this right.  I'm creating an app
that plays a sequence of audio files using mciSendString with the
"notify" flag.  When the list is started, the Hook sub is called (in the
module code below)to begin trapping messages and the first file begins.
When the MM_MCINOTIFY message is recieved, the program goes to a sub to
start the next file etc.,etc.  When the end of the list is reached the
UnHook sub is called to stop trapping messages.  It appears to work
quite well, but since this is my first app that uses subclassing I'd
like to be sure I'm going about it the right way.  Judging from the code
below, am I checking for and handling Windows messages properly? (I have
posted only the code assosciated with trapping messages for clarity.)

Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA"
(ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, _
ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA"
(ByVal hwnd As Long, _
ByVal nIndex As Long, ByVal dwNewLong As Long) As Long

Public Const MM_MCINOTIFY = &H3B9  '  MCI
Public Const GWL_WNDPROC = -4
Public lpPrevWndProc As Long
Public gHwnd As Long

Public Sub Hook()
lpPrevWndProc = SetWindowLong(gHwnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub

Public Sub Unhook()
Dim temp As Long
temp = SetWindowLong(gHwnd, GWL_WNDPROC, lpPrevWndProc)
End Sub

Function WindowProc(ByVal hw As Long, ByVal uMsg As Long, ByVal wParam
As Long, ByVal lParam As Long) As Long

'The next line calls the sub I want when the message is recieved
If uMsg = MM_MCINOTIFY Then Form1.Playit

WindowProc = CallWindowProc(lpPrevWndProc, hw, uMsg, wParam, lParam)
End Function

Tue, 12 Sep 2000 03:00:00 GMT  
 [ 1 post ] 

 Relevant Pages 

1. How do I access MCISendString Function

2. mciSendString questions

3. callback in mciSendString - how?

4. mcisendstring not working on some mpeg files

5. Problem on mciSendString record mu-law wave

6. How to use mcisendstring for multiple CD Drives?

7. using mcisendstring to cut wav-files

8. u?ycie MCISendString

9. Use mcisendstring in VB6

10. Controlling 2nd CD-ROM drive using mciSendString?

11. API mciSendString OK in ide mode, fails as exe

12. How to use mciSendString with spaces in filename ?


Powered by phpBB® Forum Software