.H
// Generated message map functions
//{{AFX_MSG(CConnectThread)
//}}AFX_MSG
afx_msg LRESULT OnThreadMessage(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
.CPP
BEGIN_MESSAGE_MAP(CConnectThread, CWinThread)
//{{AFX_MSG_MAP(CConnectThread)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_THREADMSG, OnThreadMessage)----出错
//ON_THREAD_MESSAGE(WM_THREADMSG, OnThreadMessage)
END_MESSAGE_MAP()
afx_msg LRESULT CConnectThread::OnThreadMessage(WPARAM wParam, LPARAM lParam)
{
switch(wParam)
{
case 0: // destroy data socket
m_ConnectSocket.DestroyDataConnection();
break;
case 1: // quit !
PostThreadMessage(WM_QUIT,0,0);
break;
default:
break;
}
return 0L;
}
d:\ConnectThread.cpp(146) : error C2440: “static_cast” : 无法从“LRESULT (__thiscall CConnectThread::* )(WPARAM,LPARAM)”转换为“LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)”
/////////////////////////////////////////
void OnThreadMessage(WPARAM wParam, LPARAM lParam);
DECLARE_MESSAGE_MAP()
.CPP
BEGIN_MESSAGE_MAP(CConnectThread, CWinThread)
//{{AFX_MSG_MAP(CConnectThread)
//}}AFX_MSG_MAP
//ON_MESSAGE(WM_THREADMSG, OnThreadMessage)----出错
ON_THREAD_MESSAGE(WM_THREADMSG, OnThreadMessage)
END_MESSAGE_MAP()
void CConnectThread::OnThreadMessage(WPARAM wParam, LPARAM lParam)
{
switch(wParam)
{
case 0: // destroy data socket
m_ConnectSocket.DestroyDataConnection();
break;
case 1: // quit !
PostThreadMessage(WM_QUIT,0,0);
break;
default:
break;
}
return;
}
////////////////////////////////////