资 源 简 介
这是VC++ 制作的 TextProgress文本进度条样例,可自定义步长和进度条数字变化范围,根据窗口中的提示设置相关参数后,即可看到进度条的变化效果,下面是具体的实现代码:
void CTextProgressDlg::OnButtonStart()
{
UpdateData();
m_ctrProgressBar.SetPos(0);//设定当前位置
m_ctrProgressBar.SetRange(m_nRangeFrom,m_nRangeTo); //设定范围
m_ctrProgressBar.SetStep(m_nStep);//设定步长
m_ctrProgressBar.SetShowText(TRUE);//允许显示文字
for (int i = 0; i <= m_nRangeTo; i++)
{
CString csText = _T("");
csText.Format("Processing completed %d%%", i/m_nStep);
m_ctrProgressBar.SetWindowText(csText); //设定文字
m_ctrProgressBar.StepIt();
}
m_ctrProgressBar.SetPos(0);
m_ctrProgressBar.SetShowText(TRUE); //显示文字
}