Enhanced ProgressBar Control v1.1


Sample Image

Environment: VC6, NT4/9x

Introduction

In this article I want to introduce enhanced ProgressBar control. I collect some ideas from article on CodeGuru and CodeProject, add some my own ideas and develop this control. I try to develop it in most common, flexible and extensible way. You can also use any standard functionality of ProgressBar and MFC wrapper CProgressCtrl.

Features:

Advanced Interface:

Text Styles (to set text format use "SetTextFormat" and "HideText"):

#define PBS_SHOW_PERCENT         0x0100
#define PBS_SHOW_POSITION        0x0200
#define PBS_SHOW_TEXTONLY        0x0300

Control Styles (use "ModifyStyle" or appropriated functions):

#define PBS_TIED_TEXT            0x1000
#define PBS_RUBBER_BAR           0x2000
#define PBS_REVERSE              0x4000
#define PBS_SNAKE                0x8000

Advanced functionality:

	void SetGradientColors(COLORREF clrStart, COLORREF clrEnd);
	void GetGradientColors(COLORREF& clrStart, COLORREF& clrEnd);

	void SetGradientColorsX(int nCount, COLORREF clrFirst, COLORREF clrNext, ...);
	const CDWordArray& GetGradientColorsX();
	
	void SetBarBrush(CBrush* pbrBar);
	CBrush* GetBarBrush();

	void SetBkColor(COLORREF clrBk);
	COLORREF GetBkColor();

	void SetBkBrush(CBrush* pbrBk);
	CBrush* GetBkBrush();

	void SetTextColor(COLORREF clrTextOnBar, COLORREF clrTextOnBk = -1);
	COLORREF GetTextColor();
	COLORREF GetTextColorOnBk();

	void SetShowPercent(BOOL fShowPercent = TRUE);
	BOOL GetShowPercent();

	void SetTextFormat(LPCTSTR szFormat, DWORD ffFormat = PBS_SHOW_TEXTONLY);
	void HideText();

	void SetTiedText(BOOL fTiedText = TRUE);
	BOOL GetTiedText();

	void SetRubberBar(BOOL fRubberBar = TRUE);
	BOOL GetRubberBar();

	void SetReverse(BOOL fReverse = TRUE);
	BOOL GetReverse();

	void SetSnake(BOOL fSnake = TRUE);
	BOOL GetSnake();

	void SetSnakeTail(int nTailSize);
	int  GetSnakeTail();

	void SetBorders(const CRect& rcBorders);
	const CRect& GetBorders();

You can use also:

See Test Project for additional information of usage.

Notes

The best view and performance you can get on HighColor(15/16 bit) and TrueColor(24/32 bit) resolutions. Control also supports 256 and 16 color modes. But in 16 colors mode you cannot use gradient, and in 256 colors mode control works slower because of usage CreateSolidBrush/FillRect instead of FillSolidRect.

Control is part of UIBits.dll and independent usage requires two additional files: DrawGdiX.h and MemDC.h

Downloads

Download demo project - 57 Kb
Download source - 12 Kb

History

August 2, 2000 - version 1.1
June 5, 2000 - version 1.0

Write me about any problem or ideas.