关于MFC 线程的建立过程
.cpp 中实现功能的主要函数
void CMFCxianchengDlg::OnBnClickedButton1()
{
// TODO: 在此添加控件通知处理程序代码
GetDlgItem(IDC_EDIT2)->GetWindowText(m_num2);
num2 = _ttoi(m_num2);
CWinThread*p = AfxBeginThread(ThreadProc2, this);
GetDlgItem(IDC_EDIT1)->GetWindowText(m_num);
num = _ttoi(m_num);
CWinThread*p2 = AfxBeginThread(ThreadProc, this);
}
UINT _cdecl CMFCxianchengDlg::ThreadProc(LPVOID lparam)
{
CMFCxianchengDlg* p2 = (CMFCxianchengDlg*)lparam;
int a = p2->num;
CString str;
str.Format(L"%d",a);
AfxMessageBox(str);
return 0;
}
UINT _cdecl CMFCxianchengDlg::ThreadProc2(LPVOID lparam)
{
CMFCxianchengDlg* p = (CMFCxianchengDlg*)lparam;
int a = p->num2;
CString str;
str.Format(L"%d", a);
AfxMessageBox(str);
return 0;
}
,h 文件中相关函数的定义
static UINT _cdecl ThreadProc(LPVOID lparam);
static UINT _cdecl ThreadProc2(LPVOID lparam);
CString m_num;
int num = 0;
int num2 = 0;
CString m_num2;