Setting a ProgressBar Control’s Foreground and Background Colors
The .NET Framework does not provide a way to set foreground color and background color of a progressbar control. This can be done using P/Invoke calls. The default color of the progressbar’s foreground or background is represented as CLR_DEFAULT. It’s not supported to deal with this value directly in .NET, so we use Color.Transparent instead to store this value. To make usage of the class more intuitive, assigning the value of its DefaultColor property to its color properties resets the property value to the default color.
The reason why we do not simply inherit from ProgressBar is that ProgressBar is a NotInheritable class.
When instantiating the class, a progressbar object must be passed to the constructor. In the constructor, the control’s foreground and background values will be reset to their default values. This is necessary to make the properties return correct values: