BOOL g_bWillExit = FALSE;
//线程函数
DWORD WINAPI ThreadFunc(PVOID param)
{
while(g_bWillExit == FALSE)
{
if(MessageBox(NULL,_T("退出线程吗?"),_T("这是线程"),MB_YESNO)==IDYES)
{
CmyfirstmfcDlg *pDlg = (CmyfirstmfcDlg*)param;
CButton *pButton = (CButton *)pDlg->GetDlgItem(IDC_BUTTON_THREAD);
pButton->EnableWindow(TRUE);
break;
}
}
return 0;
}
//创建线程
AfxBeginThread((AFX_THREADPROC)ThreadFunc, (LPVOID)this);
CButton *pButton = (CButton *)GetDlgItem(IDC_BUTTON_THREAD);
pButton->EnableWindow(FALSE);
//线程退出
OnClose()
{
g_bWillExit = TRUE;
}
0则评论给“mfc多线程”