Help with WaveOutOpen 
Author Message
 Help with WaveOutOpen

Hi,

    Could someone please tell me how to use WaveOutOpen with window
handler callback? I used the below code to playback sound in my Visual
C++ program.

waveOutOpen(WaveIn,WAVE_MAPPER,Format,(DWORD)m_hWnd,0,CALLBACK_WINDOW)

    with m_hWnd being the window handle data member of my CWnd class
(the function is called in a modeless dialog, so the handle is actually
a handle of the dialog object, of the CDialog class, which is derived
from CWnd) . However, when I run the program in release build mode, it
give me illegal operation every time I finished recording and the my
window handler is called. There is no problem when I change to function
callback (waveOutProc). And when I disabled the window message handler,
no problem occured as well. So I think the problem really lies with my
window message handler.

    What is the correct way to implement our own window message
handlers?

    Hope someone could help me out! Thank you very much.

Yours sincerely,
Soon Chieh



Sat, 03 Aug 2002 03:00:00 GMT  
 Help with WaveOutOpen
Hi Scott,

    Yes, that's what exactly I did! I put a void, and it crashed. Even the debug
version crashed under Windows NT. Without using message handlers, I can use
callback function instead. I have done that and it worked nicely in both builds.
However, I wonder why void is not permitted, since other window handlers does
permit void return, such as those handlers which handles dialog controls.

    If I use that prototype you suggested,what do I return in my function? For
example:

 LRESULT CSomeClass::OnSomeMessage(WPARAM wParam, LPARAM lParam)
{    //my code

    // how to end this function correctly?

Quote:
}

    Thank you very much! Hope you could help me with this!

Soon Chieh

Quote:


> > Hi,

> >     Could someone please tell me how to use WaveOutOpen with window
> > handler callback? I used the below code to playback sound in my Visual
> > C++ program.

> > waveOutOpen(WaveIn,WAVE_MAPPER,Format,(DWORD)m_hWnd,0,CALLBACK_WINDOW)

> >     with m_hWnd being the window handle data member of my CWnd class
> > (the function is called in a modeless dialog, so the handle is actually
> > a handle of the dialog object, of the CDialog class, which is derived
> > from CWnd) . However, when I run the program in release build mode, it
> > give me illegal operation every time I finished recording and the my
> > window handler is called. There is no problem when I change to function
> > callback (waveOutProc). And when I disabled the window message handler,
> > no problem occured as well. So I think the problem really lies with my
> > window message handler.

> >     What is the correct way to implement our own window message
> > handlers?

> >     Hope someone could help me out! Thank you very much.

> > Yours sincerely,
> > Soon Chieh

> Your own window message handlers should have a line like this in the message
> map:

>  ON_MESSAGE(WM_SOME_MESSAGE, OnSomeMessage)

> and the message handler function *must* have a prototype like this:

>  LRESULT CSomeClass::OnSomeMessage(WPARAM wParam, LPARAM lParam);

> If you prototype the function with a void return it crashes in release build.

> --
> Scott McPhillips [VC++ MVP]



Tue, 06 Aug 2002 03:00:00 GMT  
 Help with WaveOutOpen


Fri, 19 Jun 1992 00:00:00 GMT  
 Help with WaveOutOpen
Hi Scott,

    Thanks for the info! Now my code worked. Yes, Visual Studio documentation has
little regarding user defined handlers, and also callback functions. And these
delicate things aren't mentioned in books either. Most books just teach us how to do
things the 'easy' way.

Soon Chieh

Quote:

> LRESULT CSomeClass::OnSomeMessage(WPARAM wParam, LPARAM lParam)
> {    //my code
>      return 0; // 0 means the message was handled
> }

> The reason you must use exactly this prototype with ON_MESSAGE is that the MFC
> message router code constructs the call on the stack assuming this prototype.
> If you don't match it the stack gets corrupted.  The call construction code must
> be different for different messages, depending on Win32 message formats.

> Hey MS -- This is an extremely common newbie trap (three victims on the
> newsgroups just this morning).  The documentation for ON_MESSAGE fails to
> mention the required prototype.  It is mentioned under "User-Defined Handlers".
> The meaning of the return value is not explained in either place.

> --
> Scott McPhillips [VC++ MVP]



Wed, 07 Aug 2002 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. waveOutOpen ..can anyone offer any help

2. waveOutOpen callback event

3. can't use both waveInOpen and waveOutOpen under '95

4. use of waveOutOpen, waveOutPrepareHeader APIs.

5. SB Live & waveOutOpen

6. callback address to waveOutOpen

7. waveOutOpen error

8. waveOutOpen

9. waveOutOpen - Sound recording

10. HELP HELP HELP HELP HELP HELP!!!

11. HELP HELP HELP HELP HELP

12. HELP ++++++++++++++ HELP +++++++++++ HELP ++++++++++++++ HELP

 

 
Powered by phpBB® Forum Software