Re: Using a callback function name as an argument in a function



CFoneIODoc::lineCallbackFunc must be a static method. Change that to a
static method and you are good to go.

AliR.


"Dan Gistenson" <d.gistenson@xxxxxxxxxxxxx> wrote in message
news:WDbjj.51$Rg1.38@xxxxxxxxxxxxxxxxxxxxxxx
Hi.

Can someone tell me where I'm going wrong with this problem in my vc6 mfc
sdi project, and tell me how to fix it? I understand the general meaning
of
the compiler's 2664 error message, but I don't understand what's wrong
with
my approach and how to fix it. The problem lies with argument 3 of
lineInitializeEx() and/or the prototype and definition of
lineCallbackFunc().

I used Class wizard to add the member function lineCallbackFunc() to my
doc
class. The function will be used as a callback function, by using it as
the
third argument in a call to lineInitializeEx() which I hav placed in the
OnNewDocument member function of my doc class.

The compiler error message, the prototype and definition of the callback
function, and the call to lineInitializeEx() are below, in that order.
What
am I doing wrong, and how do I fix it?

The compiler error message is:
error C2664: 'lineInitializeExA' : cannot convert parameter 3 from 'void
(unsigned long,unsigned long,unsigned long,unsigned long,unsigned
long,unsigned long)' to 'void (__stdcall *)(unsigned long,unsigned
long,unsigned long,unsigned long,unsigned long,unsigned long)'
None of the functions with this name in scope match the target type

The callback function's prototype is:
void lineCallbackFunc(DWORD hDevice, DWORD dwMsg, DWORD
dwCallbackInstance,
DWORD dwParam1, DWORD dwParam2, DWORD dwParam3);

The callback function's definition is:
void CFoneIODoc::lineCallbackFunc (DWORD hDevice, DWORD dwMsg, DWORD
dwCallbackInstance,
DWORD dwParam1, DWORD dwParam2, DWORD dwParam3)
{
// My code will go here.
}

Finally, the call to lineInitializeEx() is: (Argument 3 is the issue.)
lResult = lineInitializeEx( &hLineApp, NULL, lineCallbackFunc, "TAPI
App!",
&dwNumDevs, &dwHighApiVersion, &lineInit );

Please help.
Thanks,
Dan




.



Relevant Pages


Loading