mfc多线程

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;

}

原文链接: mfc多线程 版权所有,转载时请注明出处,违者必究。
注明出处格式:流沙团 ( https://gyarmy.com/post-470.html )

发表评论

0则评论给“mfc多线程”