makoto_liang
asked on
How to show a progress bar in a dialog?
I tried to show the progress bar in a dialog. When OnInitDialog() is called, Progress bar is called at the same time. But the bar cannot be shown correctly as it cannot be shown until it finishes loading the progress bar. The code is as follows:
BOOL CEncodeProgressDlg::OnInit Dialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CProgressCtrl* m_enc = (CProgressCtrl*) GetDlgItem(IDC_ENCPROGRESS );
m_enc->SetRange( 0, 10 );
m_enc->SetStep( 1 );
for( int i = 0; i < 10; ++i )
{
int nSleepTime = MulDiv( 100, rand(), RAND_MAX );
Sleep( nSleepTime );
// 5 - Update progress control
m_enc->StepIt();
}
return TRUE; // return TRUE unless you set the focus //to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CEncodeProgressDlg::OnInit
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
CProgressCtrl* m_enc = (CProgressCtrl*) GetDlgItem(IDC_ENCPROGRESS
m_enc->SetRange( 0, 10 );
m_enc->SetStep( 1 );
for( int i = 0; i < 10; ++i )
{
int nSleepTime = MulDiv( 100, rand(), RAND_MAX );
Sleep( nSleepTime );
// 5 - Update progress control
m_enc->StepIt();
}
return TRUE; // return TRUE unless you set the focus //to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
:D