April 17th, 1999, 05:34 PM
I'm trying to create a worker thread in MFC and have the following code. Anyway, basically I want to thread the MyThredProc function. However, the compiler keeps giving me the error "error C2665: 'AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'unsigned int (void *)'". I can't figure out the reason for this. Any one have any ideas? Thanks!!!
Vince
UINT CTestView::MyThreadProc(LPVOID pParam)
{
int i = 0;
while (i == 0) {
CClientDC dc(this);
dc.TextOut(1, 1, "Hello");
}
return 0;
}
void CTestView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
LPVOID pParam = NULL;
switch (nChar)
{
case 'L':
AfxBeginThread(MyThreadProc, pParam);
break;
case 'M':
MessageBox("This thread works!");
break;
default:
CView::OnChar(nChar, nRepCnt, nFlags);
break;
}
}
Vince
UINT CTestView::MyThreadProc(LPVOID pParam)
{
int i = 0;
while (i == 0) {
CClientDC dc(this);
dc.TextOut(1, 1, "Hello");
}
return 0;
}
void CTestView::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
LPVOID pParam = NULL;
switch (nChar)
{
case 'L':
AfxBeginThread(MyThreadProc, pParam);
break;
case 'M':
MessageBox("This thread works!");
break;
default:
CView::OnChar(nChar, nRepCnt, nFlags);
break;
}
}