Error message: Error c2665: 'afxbeginthread': none of the 2 overloads can convert parameter 1 from type 'unsigned int (void *)'
Today, I used winsdk to write a thread in the company. When I came back, I wanted to write it using some encapsulation classes of MFC. I found it was really simple and many parameters were not used.
Use afxbeginthread to create a thread pointer, that is, cwinthread * thread.
Let's take a look at the Code:
Cwinthread * thread;
Thread = afxbeginthread (threadcallfunc, (lpvoid) This );
Because threadcallfunc is a callback function of a thread, I use Class Wizard to add a member function to the View class,
The generated function is
Uint cvedioview: threadcallfunc (lpvoid pparam)
{
Return 0;
}
After compilation, the following error occurs: Error c2665: 'afxbeginthread': none of the 2 overloads can convert parameter 1 from type 'unsigned int (void *)'
Google many times said that the callback function must be static. The final problem is that you should not use Class Wizard to add member functions to the View class, but add a function in CPP, that is:
Uint threadcallfunc (lpvoid pparam)
{
Return 0;
}
That's all.