MFC-创建线程AfxBeginThread

VS2012

 

/*
    创建线程
*/
UINT DemoA(LPVOID PpARAM)
{
    for (int i = 0; i < 100; i++)
    {
        ::SetDlgItemInt(AfxGetApp()->m_pMainWnd->m_hWnd,IDC_STATIC_OUTPUT,i,false);
        Sleep(1000);
    }

    return 0;
}


void CDemoDlg::OnBnClickedButton1()
{
    // TODO: 在此添加控件通知处理程序代码

    //创建线程
    AfxBeginThread(DemoA, NULL);//传参数不用为NULL

}

Caesar卢尚宇

2021年1月6日

原文地址:https://www.cnblogs.com/nxopen2018/p/14243828.html