Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 18: Progress-Based Controls Visual C++ and MFC Fundamentals


18.2.2..Progress Bar Properties......................................................................


To create a progress control, on the Controls toolbox, you can click the Progress button

and click the desired area on the parent window. The progress control is based on
the CProgressCtrl class, which can help you dynamically create the control.

After adding a progress control to a host, it assumes a horizontal orientation by default. If
you want the progress control to be vertical, check its Vertical property or set it to True.
If you are dynamically creating the control and you want it vertical, add the
PBS_VERTICAL style to it.

A progress bar displays regular small rectangles inside a longer or taller rectangle. This
outside rectangle serves as their border. If you do not want the border that delimits the
control, uncheck its default checked Border property or set it to False. The small
rectangles appear distinct from one another. If you do not want the small rectangles
visible, you can create a smooth progress bar by checking the Smooth property or setting
it to True. This is equivalent to adding the PBS_SMOOTH style.

Practical Learning: Creating a Progress Bar



  1. From the Controls toolbox, click the Progress button and click on the right side
    of the Hours label

  2. Using the Properties window, check its Smooth check box or set it to True

  3. Change its ID to IDC_PRGS_HOURS

  4. In the same way, add a Smooth progress bar to the right side of the Minutes label.
    Change its ID to IDC_PRGS_MINUTES

  5. Once more, add a Smooth progress control to the right side of the Seconds static
    control and change its ID to IDC_PRGS_SECONDS

  6. Add a Static Text control to the right side of the Hours progress control and change
    its ID to IDC_VAL_HOURS

  7. Add another Static Text control to the right side of the Minutes progress bar and
    change its ID to IDC_VAL_MINUTES

  8. Add another Static Text control to the right side of the Seconds progress bar and
    change its ID to IDC_VAL_SECONDS

  9. Add a Static Text to the top right section of the dialog box and set its Caption to
    Time

Free download pdf