-
AfxBeginThread problem
Hi, AfxBeginThread() gives me error C2665:
Code:
error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'UINT (LPVOID)'
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxwin.h(4108): could be 'CWinThread
*AfxBeginThread(CRuntimeClass *,int,UINT,DWORD,LPSECURITY_ATTRIBUTES)' while trying to match the argument list
'(overloaded-function)'
This is my thread function:
Code:
....
// Declaration
UINT ListenToClient(LPVOID pParam);
....
....
// Definition
UINT CServerDlg::ListenToClient(LPVOID pParam)
{
int index = 0, iReturn;
char szServerA[100];
TCHAR szServerW[100];
.......
.......
.......
}
.....
How to fix this please?
Thx.
-
Don't use a class member function.
--
Mats
-
and use correct function prototype
-
To me, the function prototype looks fine.
But an alternative would be to inherit CWinThread into CServerDlg, and passing an instance of the class into the AfxBeginThread - although I'm not sure that's what you actually want to do.
--
Mats
-
I made my own template function to wrap AfxBeginThread to be able to thread within class member functions, in case anyone wants to use it.
It's templates and may be a bit hard to understand, but it's standards compliant C++.