Skip to main content
Email Password   helpLost your password?

Dual Preview - 01-DualPreview.png - 600 x 252 - 53049 bytes

Introduction

Originally developed based on the work of Chris Maunder on CProgressBar. This CSkinProgress class intend to be used everywhere some calculations are needed. It features :

All features can be changed during run-time :

Now the explanation of the features...

Features

1. Mode

CSkinProgress allows to create a progress bar in a status bar or in a dialog. All depends on the constructor you will use and which parameters you will provide to CSkinProgress.

Status Bar

Status Bar - 02-StatusBar.png - 14868 bytes - 600 x 365

CSkinProgress
(
  LPCTSTR  i_poStrMessage,
  int      i_nUpper       = 100,
  int      i_nProgress    = cSPT_PERCENT,
  int      i_nPane        = 0,
  int      i_nSize        = 200,
  CBitmap* i_poBitmap     = NULL
#ifdef dCSP_SLIDERBAR_METHOD
 ,BOOL     i_bReverse     = false
#endif // dCSP_SLIDERBAR_METHOD

);

With this constructor you can create a progress bar with text, completion status, select the pane, the bitmap and if the progress bar have to be displayed from the end.

Dialog

Dialog - 03-Dialog.png - 14139 bytes - 600 x 367

#ifdef dCSP_DIALOG_PROGRESS
CSkinProgress
(
  CWnd*    i_poWndProgress,
  int      i_nUpper       = 100, 
  CBitmap* i_poBitmap     = NULL,
#ifdef dCSP_SLIDERBAR_METHOD
  BOOL     i_bReverse     = false,
#endif // dCSP_SLIDERBAR_METHOD

  CWnd*    i_poWndMessage = NULL,
  LPCTSTR  i_poStrMessage = NULL,
  int      i_nProgress    = cSPT_NONE
);
#endif // dCSP_DIALOG_PROGRESS

If the dCSP_SLIDERBAR_METHOD define is activated, you can use this constructor to create a progress bar inany CWnd object with a parent (important) in the dialog. You don't have to provide a pane number, but a CWnd anchor used to create the progress bar, and another CWnd in which the text will be displayed.

2. Sizing

You can provide a size for the progress bar. This size is only used when the progress bar is located in the status bar and in pane 0, thus share it with the text. You can select 3 modes of text sharing :

Positive size

Positive size - 04-PosSize.png - 11841 bytes - 600 x 120

If the given size is positive, the size of the progress bar is FIXED. Thus the text is wrapped if there is not enough place.

Zero size

Zero size - 05-ZeroSize.png - 11613 bytes - 600 x 120

If the given size is null, the size of the progress bar fits the remaining place left by the text. Thus the text is never wrapped if there is not enough place. It can only be if there is a completion message that takes too much place.

Negative size

Negative size - 06-NegSize.png - 12516 bytes - 600 x 120

If the given size is negative, the size of the progress bar fits the remaining place left by the text if there is no enough place, otherwise the given size is used.

3. Text

You can provide any text you want (Note: not too long - up to 128 characters).

Text one - 07-TextOne.png - 13150 bytes - 600 x 80

Text two - 08-TextTwo.png - 10867 bytes - 600 x 80

4. The Panes

You can create as many panes as you want in the status bar, just follow these rules...

Add an ID in the string table, in the ID_INDICATORS section, otherwise the text will appears in the pane. The longer the text, the more the width of the pane will be important !

String table - 09-StringTable.png - 40318 bytes - 600 x 181

Now add this user pane ID in the 'indicators' array in the beginning of the 'MainFrm.cpp' file. First entry is pane 0.

Main Frm - 10-MainFrm.png - 35606 bytes - 600 x 160

Then, select the pane number you will use to display the progress bar. For instance, the user pane is number 0 where the text is located :

Pane 0 - 11-PaneZero.png - 9964 bytes - 600 x 80

Pane 1 - 12-PaneOne.png - 10062 bytes - 600 x 80

You can even use system panes, such pane 3 where the NUM-LOCK indicator is located:

Pane 3 - 13-PaneThree.png - 9925 bytes - 600 x 80

5. The completion message

You can ask to CSkinProgress to add a message at the end of your text in order to provide the current completion status. The progress bar gives a graphical information, but sometimes it is useful to have more information. An enum list is fitted with increasing value with a different meaning for each of them. Here are the different kinds of messages :

6. The bitmap

You can select the default and embedded bitmap (which is the same as IDB_BMP_AQUA) or use a resource bitmap (needs to change conditions for the compilation and modify the code in CSkinProgress::SetBitmap(...))

Default bitmap - 19-BitmapDefault.png - 10328 bytes - 600 x 80

You can also provide a bitmap to the CSkinProgress

User bitmap - 20-BitmapLuna.png - 9698 bytes - 600 x 80

7. Reverse display

When not selected, the progress bar start from the left (or top in a vertical progress bar).

Normal display - 21-Normal.png - 10626 bytes - 600 x 80

For some reasons you can select to display the progress bar from its end. Especially useful for vertical bar in dialog, so that it starts from the bottom, like a thermometer.

Reverse display - 22-Reverse.png - 10780 bytes - 600 x 80

The Code

Constructors

Status bar

CSkinProgress::CSkinProgress
( // Default constructor

)

Create a default progress bar in the status bar with "Work in progress" and the default constructor values given below.

CSkinProgress::CSkinProgress
( // Default constructor with parameters for status bar usage

  LPCTSTR     i_poStrMessage, // Text to display

  int         i_nUpper,       // = 100          : Default range from 0 to 

                              //                  i_nUpper

  int         i_nProgress,    // = cSPT_PERCENT : Message type to add to the 

                              // text

  int         i_nPane,        // = 0            : Pane number in which 

                              // display the progress bar

  int         i_nSize,        // = 200          : Size of the progress bar if 

                              //                  in pane 0

  CBitmap*    i_poBitmap      // = NULL         : Pointer to a user bitmap

#ifdef dCSP_SLIDERBAR_METHOD
 ,BOOL        i_bReverse      // = false        : Reverse display of the 

                              // progress bar

#endif // dCSP_SLIDERBAR_METHOD

)

WARNING : This constructor has changed since the original version 1.00/1.12dev !

The most simple status bar constructor is :

CSkinProgress::CSkinProgress
( // Default constructor with parameters for status bar usage

  LPCTSTR     i_poStrMessage, // Text to display

)

Dialog

#ifdef dCSP_DIALOG_PROGRESS
CSkinProgress::CSkinProgress
( // Default constructor with parameters for dialog usage

  CWnd*       i_poWndProgress,  // Pointer to the anchor CWnd to use for the 

                                // progress bar

  int         i_nUpper,         // = 100,      : Default range from 0 to 

                                // i_nUpper

  CBitmap*    i_poBitmap,       // = NULL      : Pointer to a user bitmap

#ifdef dCSP_SLIDERBAR_METHOD
  BOOL        i_bReverse,       // = false,    : Reverse display of the 

                                //               progress bar

#endif // dCSP_SLIDERBAR_METHOD

  CWnd*       i_poWndMessage,   // = NULL,     : Pointer to the anchor CWnd

                                //               to use for the text pane

  LPCTSTR     i_poStrMessage,   // = NULL      : Text to display,

  int         i_nProgress       // = cSPT_NONE : Message type to add to the

                                //               text

)
#endif // dCSP_DIALOG_PROGRESS

To use the dialog constructor, make sure the dCSP_DIALOG_PROGRESS define is set. You can bypass the text pane declaration, as I have put the i_bReverse parameter in the middle of the function parameter list. Beware of your coding, you may use also the dCSP_SLIDERBAR_METHOD define yourself in order to provide conditionnal compilated facilities to your own code.

The most simple status bar constructor is :

CSkinProgress::CSkinProgress
( // Default constructor with parameters for status bar usage

  CWnd*       i_poWndProgress,  // Pointer to the anchor CWnd to use for the 

                                // progress bar

)

Destructor

CSkinProgress::~CSkinProgress
( // Destructor

)

Bitmap Process

BOOL CSkinProgress::SetBitmap
( // Change of progress bar image

  CBitmap* i_poBitmap           // = NULL : Pointer to an existing bitmap

#ifndef dCSP_TIMED_REDRAW
 ,BOOL     i_bDisplay           // = true : Display the changes

#endif // dCSP_TIMED_REDRAW

)

The two following addi(c)tive functions are used by CSkinProgress::SetBitmap(...) in order to copy/convert TRUE/COLOR bitmap pictures (don't support mapped color bitmap yet). They can be used for your own purposes :

BOOL CSkinProgress::CopyBitmap
( // Copy a bitmap

  CBitmap* o_poBitmap,          // Pointer to an EXISTING but NOT INITIALIZED 

                                // bitmap

  CBitmap* i_poBitmap           // Pointer to the source bitmap

)
BOOL CSkinProgress::ConvBitmap
( // Convert a bitmap to a specified device context

  CBitmap*    o_poBitmap,       // Pointer to an EXISTING but NOT INITIALIZED 

                                // bitmap

  CBitmap*    i_poBitmap,       // Pointer to the source bitmap

  CDC*        i_poDC            // = NULL : Pointer to the DC to use for the

                                // conversion, if NULL use the current DC

)

Progress Interface

BOOL CSkinProgress::SetRange
( // Set the new range

  int  i_nLower,                // Minimum limit

  int  i_nUpper,                // Maximum limit

  int  i_nStep,                 // = 1     : Step increment

  BOOL i_bResamble              // = false : Resample the current position 

                                // from the new Lower and Upper values

#ifndef dCSP_TIMED_REDRAW
 ,BOOL i_bDisplay               // = true  : Display the changes

#endif // dCSP_TIMED_REDRAW

)
int CSkinProgress::SetPos
( // Set <M_NRIGHT> value

  int  i_nPos                   // Set a new current position

#ifndef dCSP_TIMED_REDRAW
 ,BOOL i_bDisplay               // = true : Display the changes

#endif // dCSP_TIMED_REDRAW

)
int CSkinProgress::OffsetPos
( // Forward of <NOFFSET> value

  int  i_nOffset                // Add the offset to the current position 

                                // (can be negative)

#ifndef dCSP_TIMED_REDRAW
 ,BOOL i_bDisplay               // = true : Display the changes

#endif // dCSP_TIMED_REDRAW

)
int CSkinProgress::SetStep
( // Set <M_NSTEP> value

  int i_nStep                   // Set the step increment

)             
int CSkinProgress::StepIt
( // Forward of <M_NSTEP> value

#ifndef dCSP_TIMED_REDRAW
  BOOL i_bDisplay               // = true : Display the changes

#endif // dCSP_TIMED_REDRAW

) 

Extended Progress Interface

BOOL CSkinProgress::SetSize
( // Set size of the progress bar in pane 0 

  int  i_nSize                  // Set the size of the progress bar

#ifndef dCSP_TIMED_REDRAW
 ,BOOL i_bDisplay               // = true : Display the changes

#endif // dCSP_TIMED_REDRAW

)
int CSkinProgress::GetSize
( // Get width or height of the progress bar in pixel, mostly used in 

  // CSkinSlider

)
int CSkinProgress::GetPos
( // Get <M_NRIGHT> value

  BOOL i_bPercent               // = false

)
int CSkinProgress::GetStep
( // Get <M_NSTEP> value

)
int CSkinProgress::GetLower
( // Get <M_NLOWER> value

)
int CSkinProgress::GetUpper
( // Get <M_NUPPER> value

)
#ifdef dCSP_SLIDERBAR_METHOD
int CSkinProgress::SetStart
( // Set <M_NLEFT> value

  int  i_nStart                 // Set a new start position

#ifndef dCSP_TIMED_REDRAW
 ,BOOL i_bDisplay               // = true : Display the changes

#endif // dCSP_TIMED_REDRAW

)
#endif // dCSP_SLIDERBAR_METHOD

#ifdef dCSP_SLIDERBAR_METHOD
int CSkinProgress::GetStart
( // Get <M_NLEFT> value

  BOOL i_bPercent               // = false

)
#endif // dCSP_SLIDERBAR_METHOD

void CSkinProgress::Reset
( // Reset the progress bar

#ifndef dCSP_TIMED_REDRAW
  BOOL i_bDisplay               // = true : Display the changes

#endif // dCSP_TIMED_REDRAW

)

Text Interface

BOOL CSkinProgress::SetText
( // Set the new text

  LPCTSTR i_poStrMessage        // New text to display      

#ifndef dCSP_TIMED_REDRAW
 ,BOOL    i_bDisplay            // = true : Display the changes

#endif // dCSP_TIMED_REDRAW

)
BOOL CSkinProgress::SetProgress
( // Set <M_NPROGRESSTEXT> value

  int  i_nProgress              // Set progress text

#ifndef dCSP_TIMED_REDRAW
 ,BOOL i_bDisplay               // = true : Display the changes

#endif // dCSP_TIMED_REDRAW

)
int CSkinProgress::GetProgress
( // Get <M_NPROGRESSTEXT> value

)

Update Process

BOOL CSkinProgress::RefreshPanes
( // Resize the text pane and the progress bar

) 

Compiling the Source

Manage the CSkinProgress features with conditionnal compilation ! Here the explanation of each compilation define :

Specific defines are used for very experimental purposes, use them with care :

The Progress Bar Bitmap

Now to finish this little introduction to the CSkinProgress graphic engine, the overview of the method used to create the progress bar picture. A bitmap is provided to CSkinProgress::SetBitmap(...)...

Photon bar - 23-Photon.png - 389 bytes - 180 x 32

This bitmap is divided into 9 parts...

Bitmap cutted into pieces - 24-PhotonCutted.png - 557 bytes - 180 x 32

From left to right, here are the meaning and associated ID define :

To create your own bitmap skin, make any bitmap with 9 parts like above. The height of the bitmap is not really important (BTW not too large - no more than 32 pixels, of course) and the width should be multiple of 9 (important), thus : width % 9 = 0 ! Have a look at the bonus/hidden bitmaps to understand that/how CSkinProgress allows you to make funny things ;)

Relative positions of the keys elements are calculated on the range of the progress bar and its current position. Then, once get these values as percent, calculate the absolute positions of these key elements. There is now just the place them on the progress bar image in a defined order so that some elements could hide some others, like on layers in Paint Shop Pro.

Blue columns are the exact positions of the elements.
Red columns are the base columns based on the width of an element.

Pseudo layers - 25-PhotonParts.png - 37743 bytes - 600 x 450

The three/four letters are the key of comments into the CSkinProgress::OnPaint() function for you to spot them easily...

Version history

Rev 1.02 : July 12 2003 14:01:53 (Kochise)

Base : CSkinProgress 1.32dev

Rev 1.01 : July 06 2003 22:08:37 (Kochise)

Base : CSkinProgress 1.28 Devel

Rev 1.00 : May 25 2003 13:25:12 (Kochise)

First archived version and released onto CodeProject.
Base : CSkinProgress 1.12 Devel
You must Sign In to use this message board.
 
 
Per page   
 FirstPrevNext
GeneralDude.... Pin
mkriese
8:55 25 Aug '08  
GeneralRe: Dude.... Pin
Kochise
8:16 1 Oct '08  
QuestionFile(s) Copy progress Pin
UltraWhack
9:33 18 Dec '06  
AnswerRe: File(s) Copy progress Pin
Kochise
9:43 18 Dec '06  
GeneralRe: File(s) Copy progress Pin
UltraWhack
11:41 18 Dec '06  
GeneralRe: File(s) Copy progress Pin
Kochise
10:37 19 Dec '06  
GeneralGreat stuff - two issues Pin
nadiric
7:39 28 Sep '06  
GeneralRe: Great stuff - two issues Pin
Kochise
22:18 28 Sep '06  
GeneralRe: Great stuff - two issues Pin
nadiric
7:47 29 Sep '06  
GeneralDebug Assertion Failed in wincore Line 880 Pin
evil-peter
1:00 20 Jun '06  
GeneralRe: Debug Assertion Failed in wincore Line 880 Pin
Kochise
22:33 20 Jun '06  
GeneralRe: Debug Assertion Failed in wincore Line 880 Pin
evil-peter
0:12 21 Jun '06  
GeneralRe: Debug Assertion Failed in wincore Line 880 Pin
Kochise
4:12 21 Jun '06  
GeneralRe: Debug Assertion Failed in wincore Line 880 [modified] Pin
evil-peter
6:35 21 Jun '06  
GeneralThe threat has started here : Pin
Kochise
23:18 3 Jul '06  
GeneralRe: The threat has started here : Pin
evil-peter
2:41 4 Jul '06  
GeneralRe: The threat has started here : Pin
Kochise
23:09 4 Jul '06  
QuestionHow to put test in another pane than 0 Pin
jongallegraud
7:13 20 Mar '06  
AnswerRe: How to put test in another pane than 0 Pin
Kochise
10:01 26 Mar '06  
Generalwhat a cool progress bar ! Pin
unionize
6:45 29 Jun '05  
GeneralRe: what a cool progress bar ! Pin
Kochise
12:04 5 Jul '05  
GeneralRe: what a cool progress bar ! Pin
Einst
20:33 14 Jan '06  
GeneralLicense for CSkinProgress Pin
Kochise
3:44 24 Jan '06  
GeneralVertical? Pin
Alan Moore
9:41 18 May '05  
GeneralOups... Pin
Kochise
20:56 19 May '05  


Last Updated 11 Jul 2003 | Advertise | Privacy | Terms of Use | Copyright © CodeProject, 1999-2009