Click here to Skip to main content
12,816,406 members (31,360 online)
Click here to Skip to main content
Add your own
alternative version


12 bookmarked
Posted 25 May 2003

Round / Spherical Progress Control

, 25 May 2003
Rate this:
Please Sign up or sign in to vote.
A progress control that can display progress as depth, area or volume of a sphere.

Sample Image - RoundProgress.jpg


The title is pretty self explanatory. The control displays a circle / ellipse and fills it depending on the progress position. The circle's thickness and color can be changed. As can the colors of the filled and empty areas. The clever bit is how the position is represented. The progress can be used as proportional depth, area or volume of a sphere.


In the MFC forums, someone was asking how to draw a partially filled circle. They had a need to display liquid level in a sphere. One bored Sunday afternoon later, my first article was born.

Using the code

This control simply subclasses an existing progress control. Either using class wizard, or by typing, subclass a progress control with CRoundProgressCtrl instead:

In your dialog definition:
class CMyDialog : public CDialog
CRoundProgressCtrl m_Sphere;

In your DoDataExchange method, place the following code:

void CMyDialog::DoDataExchange (CDataExchange *pDX)
DDX_Control(pDX, IDC_PROGRESS1, m_Progress1);

Or in the OnInitDialog method, have the following code:

BOOL CMyDialog::OnInitDialog()
m_Progress1.SubclassDlgItem (IDC_PROGRESS1, this);

CRoundProgressCtrl inherits all the methods of CProgressCtrl and adds a few of its own:

enum RoundStyle { roundDepth = 0, roundArea, roundVolume };
RoundStyle SetRoundStyle (RoundStyle r);
RoundStyle GetRoundStyle () const { return m_RoundStyle; }
UINT SetLineThickness (UINT l);
UINT GetLineThickness () const { return m_nLineThickness; }
COLORREF GetColorLine () const { return m_clrLine; }
COLORREF GetColorFill () const { return m_clrFill; }
COLORREF GetColorEmpty () const { return m_clrEmpty; }

The actions of these functions are fairly plain. The Set functions set the current setting before the change. Setting the colors to CLR_DEFAULT will set the control to use the same colors as a progress control. Setting the line thickness to 0 will turn it off. 1 or more will display the line.


As drawing the ellipse is a multistage operation, I've used Keith Rule's CMemDC class. I BitBlt the existing image to the memory DC first, in order to make the area outside the ellipse "transparent".


  • 26 May 2003

    Version 1.0 released. No known bugs, but I should hope not in such a small code snippet!


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Iain Clarke, Warrior Programmer
Software Developer (Senior)
Sweden Sweden
I have now moved to Sweden for love, and recently married a lovely Swede.

I started programming on BBC micros (6502) when I was six and never quite stopped even while I was supposed to be studying physics and uni.

I've been working for ~13 years writing software for machine control and data analysis. I now work on financial transaction transformation software, for a Software company in Gamlastan, Stockholm.
Look at my articles to see my excellent coding skills. I'm modest too!

You may also be interested in...


Comments and Discussions

GeneralSeries of circles Pin
Jolyn13-Dec-03 15:31
memberJolyn13-Dec-03 15:31 
GeneralRe: Series of circles Pin
Iain Clarke5-Jan-04 6:42
memberIain Clarke5-Jan-04 6:42 
GeneralOne step away from the IE Spinning Globe. Pin
WREY3-Jun-03 12:42
memberWREY3-Jun-03 12:42 
GeneralEclipsis as progress control Pin
Martin Holzherr26-May-03 22:14
memberMartin Holzherr26-May-03 22:14 
GeneralRe: Eclipsis as progress control Pin
Iain Clarke26-May-03 23:36
memberIain Clarke26-May-03 23:36 
GeneralWeird Pin
dog_spawn26-May-03 5:03
memberdog_spawn26-May-03 5:03 
GeneralRe: Weird Pin
Iain Clarke26-May-03 6:13
memberIain Clarke26-May-03 6:13 
GeneralRe: Weird Pin
yarp26-May-03 21:29
memberyarp26-May-03 21:29 
GeneralRe: Weird Pin
Ed Gadziemski27-May-03 4:27
memberEd Gadziemski27-May-03 4:27 
GeneralRe: Weird Pin
Simon Hofverberg2-Jun-03 22:07
memberSimon Hofverberg2-Jun-03 22:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170308.1 | Last Updated 26 May 2003
Article Copyright 2003 by Iain Clarke, Warrior Programmer
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid