Progress Bars

A progress bar is a window that an application can use to visually track the progress of a lengthy operation such as an installation or a file copying task. A progress bar has a range, which represents the entire duration of the operation, and a current position, which represents the progress the application has made toward completing the operation. The application sets both the range and the current position (as it does for a scroll bar) and has the ability to advance the current position.

The window procedure uses the range and the current position to determine how much of the bar should be filled with the highlight color. By default, the minimum range of a progress bar is 0, and the maximum range is 100. The increment value is set to 10.

The PROGRESS sample, which I wrote to demonstrate how to create and manipulate progress bars, simply creates one of these controls, sets its range, and allows the user to start and stop the process of filling the bar with the highlight color. I used a timer to simulate a lengthy operation. Figure 2-5 shows the PROGRESS sample.

Figure 2-5.

The PROGRESS sample.