在头文件中定义 :
类内部:
CWinThread * pThread;
类外部:
struct threadInfo
{
UINT nMilliSecond;
CProgressCtrl* pctrlProgress;
};
UINT ThreadFunc(LPVOID lpParam); //线程执行函数
在CPP文件中定义:
threadInfo Info;
UINT ThreadFunc(LPVOID lpParam)
{
threadInfo* pInfo=(threadInfo*)lpParam;
//MessageBoxW(NULL,a);
for(int i=0;i<100;i++)
{
int nTemp=pInfo->nMilliSecond;
pInfo->pctrlProgress->SetPos(i);
//Sleep(nTemp);
}
return 0;
}
在OnInitDialog()类添加
Info.nMilliSecond=m_nMilliSecond;
Info.pctrlProgress=&m_ctrlProgress;
pThread=AfxBeginThread(ThreadFunc, &Info);