Title:         Windows Progress Bar Control
Author:        Philip J. Erdelsky, 75746.3411@compuserve.com
Language:      Turbo C/C++ 3.1 for Windows
Platform       Windows 3.1
Portability:   Other Windows C++ compilers, with slight changes
Restrictions:  Public domain, no restrictions on use
Date:          January 10, 1995
Keywords:      Windows Custom Control, Progress, Completion

Abstract:      A windows custom control for a progress bar or completion
               bar, which shows the percentage of completion of a
               process as a numerical value and also by a partly
               filled-in bar. C++ source code only; no VBX file.

The "PROGRESSBAR" control is a simple, common control that does not
appear among the Windows standard controls. Its purpose is to show the
percentage of completion of a process, both as a numerical value and by
a partly filled-in bar. It is a completely passive control which changes
only in response to messages sent by its parent.

You can put a "PROGRESSBAR" control into a dialog box by including a
line of the following form in the appropriate place in the resource
(.RC) file:

     CONTROL 0, control_id, "PROGRESSBAR", WS_CHILD | WS_VISIBLE,
       x, y, width, height

You can also put a "PROGRESSBAR" control into a dialog box with the
Borland Resource Workshop, by selecting a custom control and then
entering the class name "PROGRESSBAR" instead of choosing one of the
predefined classes.

You can also create a "PROGRESSBAR" control dynamically with an
appropriate call on CreateWindow().

The control keeps track of two values, which are called "total" and
"completed". The default values are 100 and 0, respectively, but they
may be changed by sending messages as follows:

     SendDlgItemMessage(handle, control_id, PB_SETTOTAL, value, 0L);
     SendDlgItemMessage(handle, control_id, PB_SETCOMPLETED, value, 0L);

The control displays the following percentage (rounded downward to the
nearest integer) in the middle of the bar:

     (completed / total) * 100%

It also darkens the left side of the bar so the width of the darkened
portion and the width of the bar are in the same ratio as "completed" is
to "total".

The value of "total" must be positive, and the value of "completed" must
lie between zero and "total", inclusive. The control will fail if this
is not the case.

The values of "total" and "completed" may also be retrieved by sending
messages as follows:

     value = SendDlgItemMessage(handle, control_id, PB_GETTOTAL, 0, 0L);
     value = SendDlgItemMessage(handle, control_id, PB_GETCOMPLETED, 0,
               0L);

A "PROGRESSBAR" control does not process other messages, except for a
few that are handled internally by Windows.

The file PROGRESS.CPP must be compiled and linked with the rest of the
application. The special messages PB_SETTOTAL, PB_SETCOMPLETED,
PB_GETTOTAL and PB_GETCOMPLETED are defined in the header file
PROGRESS.H.

The files PROGTEST.CPP, PROGTEST.H and PROGTEST.RC contain a simple
test program uses a "PROGRESSBAR" control.

