进度条的代码如下:
BOOL CTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_Progress.SetRange32(0,100);
m_Progress.SetStep(5);
m_Progress.SetPos(0);
SetTimer(1,500,0);
UpdatePercentText();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CTestDlg::UpdatePercentText()
{
int nPos=m_Progress.GetPos();
int nLow,nUp;
m_Progress.GetRange(nLow,nUp);
m_strPercent.Format("%4.0f%%",(float)nPos/(float)(nUp-nLow)*100.0);
UpdateData(FALSE);
}
CScrollBar* CTestDlg::GetScrollBarCtrl(int nBar) const
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::GetScrollBarCtrl(nBar);
}
void CTestDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
UpdatePercentText();
if(m_Progress.GetPos()==100)
KillTimer(1);
m_Progress.StepIt();
CDialog::OnTimer(nIDEvent);
Sleep(50);
}
是不是我的进度条的对话框应该建成非模态的啊?请大虾指教啊 ?
BOOL CTestDlg::OnInitDialog()
{
CDialog::OnInitDialog();
m_Progress.SetRange32(0,100);
m_Progress.SetStep(5);
m_Progress.SetPos(0);
SetTimer(1,500,0);
UpdatePercentText();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CTestDlg::UpdatePercentText()
{
int nPos=m_Progress.GetPos();
int nLow,nUp;
m_Progress.GetRange(nLow,nUp);
m_strPercent.Format("%4.0f%%",(float)nPos/(float)(nUp-nLow)*100.0);
UpdateData(FALSE);
}
CScrollBar* CTestDlg::GetScrollBarCtrl(int nBar) const
{
// TODO: Add your specialized code here and/or call the base class
return CDialog::GetScrollBarCtrl(nBar);
}
void CTestDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
UpdatePercentText();
if(m_Progress.GetPos()==100)
KillTimer(1);
m_Progress.StepIt();
CDialog::OnTimer(nIDEvent);
Sleep(50);
}
是不是我的进度条的对话框应该建成非模态的啊?请大虾指教啊 ?