CProgressCtrl

CoderSource.net
CProgressCtrl
Rating:

Date: 5/1/2004 12:00:00 AM

   A Progress control is something that an application can use to indicate the progress of an ongoing operation. It consists of a rectangle that is gradually filled, from left to right, with the system highlight color as an operation progresses. This control is can be manipulated by using the class CProgressCtrl.

   This article is a brief about how to use this control with reference to the class CProgressCtrl in an MFC application with dialogs.

CProgressCtrl - Setting up the application:

   The following steps explain how to setup a basic dialog application to hold a progress bar control. If there is a dialog to hold the Progress bar (of CProgressCtrl ) the following steps can be ignored.

  • Create a new MFC AppWizard executable project as a dialog based application.
  • The application can also be an SDI/MDI app, where in the dialog can be inserted as a resource into the SDI/MDI projects.
  • From the controls toolbox, choose the progress bar control and place it on a dialog box.
  • Add a class member for the CProgressCtrl for the progress bar control. This sample assumes the variable name to be m_Progress.

CProgressCtrl - Sample usage:

   The progress control can be initialized and used wherever needed. A dialog can have multiple operations/functionalities to be supported. For each and every operation, the CProgressCtrl can be initialized and used to indicate the progress of the operation.

   The following is the sample piece of code to show the progress of a CProgressCtrl from 1 to 100 with increments of 2 at every operation.


    m_Progress.SetRange(0,100);
    m_Progress.SetStep(2);
    for(int i=0;i<50;i++)
    {
        m_Progress.StepIt();
    }


   or instead of the CProgressCtrl.SetStep() and CProgressCtrl.StepIt() combination, a single function CProgressCtrl.StePos can also be used.

   The above piece of code can be applied anywhere the control needs to be manipulated.

   Also it is to be noted that the control need not be used only by the resource editor. It can also be created dynamically by using the CProgressCtrl.Create function.

You Can Rate this Article, if you are Logged In      
 

More Links from CoderSource.net:

 
Refer to a Friend:

Your Details:

Name:     e-mail:

Friend Details:

Name:    e-mail:    


MENU
Home
MFC 
C++
.Net
WIN32
Programming
Forum
My Articles
Add to Google
Add to My Yahoo!
Welcome to Codersource.Net Login | Register | Faq  

SEARCH
Google
 

NOTES:


Thanks for visiting our CoderSource.net. This site will be improved with more articles. Interested visitors can also submit their articles through the Submit Article link.Your article will also be published after due consideration by the editor. 

© Copyright 2003. All rights on content reserved by CoderSource.net. Contact    About Us