|
Hello guys. I am trying to write a small recording program but am stuck in basics. I can not pass the pointer of the WaveInProc function properly. I am trying it in two ways, both of them widely used on online examples.
1 - rResult = ::waveInOpen(&phWaveIn, WAVE_MAPPER, &pcmWaveFormat, (DWORD)WaveInProc, 0, CALLBACK_FUNCTION);
2 - rResult = ::waveInOpen(&phWaveIn, WAVE_MAPPER, &pcmWaveFormat, (DWORD)&WaveInProc, 0, CALLBACK_FUNCTION);
3 - rResult = ::waveInOpen(&phWaveIn, WAVE_MAPPER, &pcmWaveFormat, (DWORD)(VOID*)WaveInProc, 0, CALLBACK_FUNCTION);
Their corresponding error messages are shown as under
1 - error C2440: 'type cast' : cannot convert from 'void (__stdcall CWaveApiDlg::* )(HWAVEIN,UINT,DWORD,DWORD,DWORD)' to 'DWORD'
2 - error C2276: '&' : illegal operation on bound member function expression
This is what WaveInProc looks like in my .cpp file
void CALLBACK WaveInProc(HWAVEIN hDevice, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2)
{
}
Everything seems to be fine ... what is wrong here? Thanks for any help.
This world is going to explode due to international politics, SOON.
|
|
|
|
|
Well, you are passing a pointer to a (non static ) method of class CWaveApiDlg where a function pointer is requested. You cannot do that. Either pass a (pointer to a) global function or to a static method of the class.
Veni, vidi, vici.
|
|
|
|
|
You are incorrectly trying to cast the address of the callback function to a DWORD . But according to the documentation[^], that should be a DWORD_PTR .
|
|
|
|