I'm following MFC in VC++.net 2008...
I'm using threads in my codes. The code declared as
Code:
public:
DWORD WINAPI ThreadProc(LPVOID lp);
and
Code:
BOOL CNewSerialPrintDlg::OnInitDialog()
{
CDialog::OnInitDialog();
//bla bla....
HANDLE m_RecvThread=NULL;
DWORD ThreadID = 0;
m_RecvThread = ::CreateThread(NULL,
0,ThreadProc,NULL,0,&ThreadID
);
return TRUE; // return TRUE unless you set the focus to a control
}
DWORD WINAPI CNewSerialPrintDlg::ThreadProc(LPVOID lp)
{
while(1)
{
//bla bla.....
return 0;
}
}
while compiling the error message reported as
Code:
error C3867: 'CNewSerialPrintDlg::ThreadProc': function call missing argument list; use '&CNewSerialPrintDlg::ThreadProc' to create a pointer to member
Plz help me to fix this problem.I don't have more experience on using Thread.
and in NewSerialPrint.cpp as(otherwise it makes so many errors like parameters can't be static..)
Code:
UINT WINAPI CNewSerialPrintDlg::ThreadProc1( LPVOID lpContext )
{
// Turn the passed in 'this' pointer back into a CNewSerialPrintDlg instance
CNewSerialPrintDlg* pDlg = reinterpret_cast< CNewSerialPrintDlg* >( lpContext );
while(TRUE)
{
//....
}
}
but again the same error message is coming it is like
Code:
error C3867: 'CNewSerialPrintDlg::ThreadProc1': function call missing argument list; use '&CNewSerialPrintDlg::ThreadProc1' to create a pointer to member.
error C3861: '_beginthreadex': identifier not found
how may I fix it
Last edited by arunkr6; December 23rd, 2009 at 12:35 AM.
The error refers to the code that starts the thread, not the thread procedure. You probably call it with ThreadProc1, and you should use &CNewSerialPrintDlg::ThreadProc1.
The error refers to the code that starts the thread, not the thread procedure. You probably call it with ThreadProc1, and you should use &CNewSerialPrintDlg::ThreadProc1.
Thanks Cilu, I copied that snippet over from code where everything was declared in the header, ATL style (i.e. no cpp file). I've updated the original post.
Bookmarks