Link to home
Start Free TrialLog in
Avatar of makoto_liang
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::OnInitDialog()
{
      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
}
Avatar of freshmeat
freshmeat

wow, cool idea, i wanna know how to?
:D
ASKER CERTIFIED SOLUTION
Avatar of sboucher789
sboucher789

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial