You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

86 lines
2.1 KiB
C++

#include "StdAfx.h"
#include "TimingProgressMgr.h"
#include "DlgTimingProgress.h"
#include "AllThreadMgr.h"
#include "GlobalFunction.h"
UINT TimingProgressThread(LPVOID pParam)
{
CTimingProgressMgr *p = (CTimingProgressMgr *)pParam;
p->StartTimingProgressExt();
return 0;
}
CTimingProgressMgr gTimingProgressMgr;
CTimingProgressMgr::CTimingProgressMgr(void)
{
m_StopExecute = true;
m_bExecuting = false;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>
m_bCloseApp = false;//<2F>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>йر<D0B9><D8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
m_CurExecuteTime = 0;//<2F><>ǰ<EFBFBD><C7B0>ִ<EFBFBD><D6B4>ʱ<EFBFBD><CAB1>ms
}
CTimingProgressMgr::~CTimingProgressMgr(void)
{
}
//<2F><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʾ<EFBFBD><CABE><EFBFBD><EFBFBD>
void CTimingProgressMgr::SetShowInfo(CString str)
{
m_ShowInfo = str;
}
//<2F><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD>ʱ<EFBFBD><CAB1>
void CTimingProgressMgr::SetTimingProgressTime(double ExecuteTime)
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>е<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Ҫ<EFBFBD>޸<EFBFBD>ʱ<EFBFBD><CAB1>
if(m_bExecuting)
return;
m_ExecuteTime = ExecuteTime;//ִ<><D6B4>ʱ<EFBFBD><CAB1>ms
}
//ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void CTimingProgressMgr::StopExecute()
{
m_StopExecute = true;
m_ShowInfo = "";
m_CurExecuteTime = 0;//<2F><>ǰ<EFBFBD><C7B0>ִ<EFBFBD><D6B4>ʱ<EFBFBD><CAB1>ms
}
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
void CTimingProgressMgr::StartTimingProgress()
{
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ִ<EFBFBD>е<EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>Ҫ<EFBFBD>ظ<EFBFBD><D8B8><EFBFBD><EFBFBD><EFBFBD>
if(m_bExecuting)
return;
m_StopExecute = false;
m_CurExecuteTime = 0;//<2F><>ǰ<EFBFBD><C7B0>ִ<EFBFBD><D6B4>ʱ<EFBFBD><CAB1>ms
//<2F><><EFBFBD>µ<EFBFBD><C2B5>߳<EFBFBD><DFB3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD>
//<2F><><EFBFBD><EFBFBD>Ԥ<EFBFBD>Ƚ<EFBFBD><C8BD>治Ҫ<E6B2BB><D2AA><EFBFBD><EFBFBD><EFBFBD>Ի<EFBFBD><D4BB><EFBFBD>
{
CWinThread* pThread = AfxBeginThread(TimingProgressThread,this);
if(m_bCloseApp)
{
WaitForThreadExit(pThread);//<2F>ȴ<EFBFBD><C8B4>߳̽<DFB3><CCBD><EFBFBD>
}
}
}
//<2F><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD>Ƿ񳬹<C7B7>CheckTime
bool CTimingProgressMgr::CheckCurExecuteTime(double CheckTime)
{
if(CheckTime>0)
return (m_CurExecuteTime>CheckTime);
//CheckTime <0 <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><E8B6A8><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
return (m_CurExecuteTime>m_ExecuteTime);
}
//<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʹ<EFBFBD>õı<C3B5><C4B1><EFBFBD>ֵ(0~99)
double CTimingProgressMgr::GetProgressVal()
{
double val = 100;
if(m_CurExecuteTime>0)
{
val = (m_CurExecuteTime/m_ExecuteTime)*100;
}
return val;
}
void CTimingProgressMgr::StartTimingProgressExt()
{
CDlgTimingProgress dlg;
dlg.DoModal();
}