0,
(LPTHREAD_START_ROUTINE)CProgressDialog::Thread
Proc,(LPVOID)this,0,&threadID);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return
FALSE
}
DWORD WINAPI
CProgressDialog::ThreadProc(CProgressDialog* dlg)
{
DWORD ret=dlg->ProgressProc();
dlg->PostMessage(WM_COMMAND, IDOK);
return ret;
}
void CProgressDialog::OnCancel()
{
// TODO: Add extra cleanup here
if (m_EnableCancel) m_IsCancel=TRUE;
}
void CProgressDialog::OnOK()
{
// TODO: Add extra validation here
WaitForSingleObject(m_Thread, INFINITE);
CDialog::OnOK();
}
DWORD CMyProgressDialog::ProgressProc()
{
SetMessage("Progress");
for (int i=0;i<100;i++) {
if (IsCancel()) break;
Sleep(100);
SetProgress(i);
}
return 0;
}
只需在应用Progress控件的地方调用CMyProgressDialog类的对象即可。可根据不同的应用程序修改DWORD CMyProgressDialog::ProgressProc()这个继承函数的函数体来适应相应的
程序。