Having trouble using SendMessageCallback

I'm trying to use SendMessageCallback and I've found a number of pages which cover the subject but none of them want to work for me.

eg:
http://www.experts-exchange.com/Programming/Programming_Languages/Cplusplus/Q_11664840.html?query=sendmessagecallback&clearTAFilter=true


What I have is an ATL ActiveX control where I want to Asynchronously process a function and continue processing the message queue like normal (Which is why I can't use sendMessage (because that bypasses the queue.  See answer #2 here: http://www.experts-exchange.com/Programming/Programming_Platforms/Win_Prog/Q_10149991.html?query=sendmessagecallback&clearTAFilter=true ).

This is my code:

SendMessageCallback(myClass->mhWndPlugin, WM_CUSTOMDRAW, NULL, NULL, myFunc, 0);

And my function is defined as either one of these:

// static void myFunc(HWND hwnd, UINT uMsg, ULONG_PTR dwData, LRESULT lResult) { return;}
VOID CALLBACK myFunc(  HWND hwnd,  UINT uMsg,  ULONG_PTR dwData,   LRESULT lResult ) { return; }

This is the error that I get when I try to compile:
error C2065: 'myFunc' : undeclared identifier
error C3861: 'myFunc': identifier not found, even with argument-dependent lookup

OR I get

error C2664: 'SendMessageCallbackW' : cannot convert parameter 5 from 'void (HWND,UINT,ULONG_PTR,LRESULT)' to 'SENDASYNCPROC'
        None of the functions with this name in scope match the target type
error C2664: 'SendMessageCallbackW' : cannot convert parameter 5 from 'void (HWND,UINT,ULONG_PTR,LRESULT)' to 'SENDASYNCPROC'
        None of the functions with this name in scope match the target type

depending on if I put the function inside or outside of the class.  Can anyone tell me whats wrong?

jvoros1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

jkrCommented:
Use

VOID CALLBACK myFunc(  HWND hwnd,  UINT uMsg,  DWORD dwData,   LRESULT lResult ) { return; }

SendMessageCallback(myClass->mhWndPlugin, WM_CUSTOMDRAW, NULL, NULL, myFunc, 0);

or


SendMessageCallback(myClass->mhWndPlugin, WM_CUSTOMDRAW, NULL, NULL, (SENDASYNCPROC) myFunc, 0);

if you want to enforce the usage of a different parameter type.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rajeev_devinCommented:
I tried your and it looked very strange to me.
As jkr has suggested it will be something like that.
I tried this
VOID CALLBACK myFunc(HWND hwnd, UINT uMsg, ULONG dwData, LRESULT lResult)

In fact the fourth parameter of 'SENDASYNCPROC' is ULONG and not ULONG_PTR.
0
jvoros1Author Commented:
I've tried every combonation of the above two solutions and I still can't get it to work.  I'm getting this error now:

error C2664: 'SendMessageCallbackW' : cannot convert parameter 5 from 'void (HWND,UINT,DWORD,LRESULT)' to 'SENDASYNCPROC'
        None of the functions with this name in scope match the target type
0
Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

rajeev_devinCommented:
Simply change the prototype of this function
VOID CALLBACK myFunc(HWND hwnd, UINT uMsg, ULONG dwData, LRESULT lResult)

Nothing required.
0
jvoros1Author Commented:
rajeev_devin: That code matches exactly what I have when I get the SENDASYNCPROC errors.
0
jkrCommented:
>>I've tried every combonation

also

VOID CALLBACK myFunc(  HWND hwnd,  UINT uMsg,  DWORD dwData,   LRESULT lResult ) { return; }

SendMessageCallback(myClass->mhWndPlugin, WM_CUSTOMDRAW, NULL, NULL, (SENDASYNCPROC) myFunc, 0);

?
0
jvoros1Author Commented:
That particular one gives me
error C2440: 'type cast' : cannot convert from 'overloaded-function' to 'SENDASYNCPROC'
        None of the functions with this name in scope match the target type
0
jvoros1Author Commented:
Figured it out.  I needed to make my function static.

static VOID CALLBACK myFunc(  HWND hwnd,  UINT uMsg,  DWORD dwData,   LRESULT lResult ) {}
0
jkrCommented:
>>I needed to make my function static.

Err, you never mentioned that it is about a class member...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C++

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.