Click here to Skip to main content
13,591,049 members
Click here to Skip to main content
Add your own
alternative version


39 bookmarked
Posted 10 May 2004

Progress Cell for Grid Control.

Rate this:
Please Sign up or sign in to vote.
A new cell progress-bar-like type for Chris Maunder's Grid Control.

Demo Piccie


For a recent project, I needed to monitor the progress of a variable number of long tasks. This could be from none to hundreds in the extreme case. After abandoning the idea of creating / hiding / destroying an army of actual progress controls, I hit on the idea of creating a cell type for Chris Maunder's grid control. I already knew how to use it from multiple projects. I knew it had the flexibility I needed, so it was just a case of rolling up my sleeves and writing a new CGridCell...

Using the code

Using the code should not be too tough. Just add the header to your CPP file:

#include "GridCellProgress.h"

and use the cell type as you would any other grid cell type.

CGridCellProgress *pProg;
for (int n = 0; n < 10; n++)
    m_Grid.SetCellType (n, 0, RUNTIME_CLASS(CGridCellProgress));

pProg = (CGridCellProgress *)m_Grid.GetCell (0,0);
pProg->SetText ("One");
pProg->SetPos (0);

New Cell Methods

I like to think these new cell method names are pretty self explanatory. (Yes, I'm lazy.)

virtual    BOOL    EnablePercentage (BOOL bEnable);
virtual    BOOL    EnablePathCompaction (BOOL bEnable);

virtual    void    SetRange(int nLower, int nUpper);
virtual    void    SetLower(int nLower);
virtual    void    SetUpper(int nUpper);
virtual    void    SetPos    (int nPos);
virtual void    SetColor(COLORREF clr);

virtual    void    GetRange(int &nLower, int &nUpper);
virtual    int    GetLower();
virtual    int    GetUpper();
virtual    int    GetPos    ();
virtual COLORREF GetColor();


This was tested against v2.24 of the grid control, and includes that in the sample project. From the Grid Controls page, there is a v2.25 now available. There shouldn't be any difficulty with the new version. Similarly, I haven't tested this on ME, Win 2K3, Longhorn etc. I don't anticipate problems, but you never know! I've been caught out assuming before...

I have also used Color instead of spelling it properly as Colour. I find myself typing American for SDK functions etc, and properly for my own variables. As the new cell functions imitate those of CProgressCtrl, I thought I'd better imitate the spelling too.


There are two obvious people to thank:

  • Chris Maunder for his excellent Grid control class, which I have used many times.
  • Secondly, Keith Rule for his neat and tidy CMemDC class. While I haven't used it directly here, Chris does, and I have used it elsewhere to good effect.


  • 2004 May 11th - First released into the wild.


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

GeneralMy vote of 5 Pin
manoj kumar choubey18-Feb-12 0:02
membermanoj kumar choubey18-Feb-12 0:02 
GeneralSelected cells Pin
Eugene Podkopaev3-Jul-06 0:24
memberEugene Podkopaev3-Jul-06 0:24 
GeneralRe: Selected cells Pin
Member 45771876-Oct-08 23:47
memberMember 45771876-Oct-08 23:47 
GeneralDisplaying Percentage in narrow column Pin
skonopa30-Mar-06 9:24
memberskonopa30-Mar-06 9:24 
GeneralRe: Displaying Percentage in narrow column Pin
Iain Clarke31-Mar-06 0:27
memberIain Clarke31-Mar-06 0:27 
GeneralRe: Displaying Percentage in narrow column Pin
skonopa31-Mar-06 6:57
memberskonopa31-Mar-06 6:57 
GeneralRe: Displaying Percentage in narrow column Pin
Iain Clarke2-Apr-06 21:53
memberIain Clarke2-Apr-06 21:53 
I've just added a couple of lines to my demo dialog program:
m_Grid.SetColumnCount (2); // TEST 1->2
m_Grid.SetRowCount (10);
m_Grid.SetFixedRowCount (1); // TEST
m_Grid.ExpandColumnsToFit ();

in order to test the problems, and I don't see the effects you are describing. The strings collapse to a single character and a single dot, while the percentages just get drawn right-justified.

When the article was written, I was running Win2K, but my dev machine is now XP.

What OS are you running on?

GeneralRe: Displaying Percentage in narrow column Pin
skonopa4-Apr-06 3:46
memberskonopa4-Apr-06 3:46 
GeneralFound weird bug Pin
skonopa30-Mar-06 9:07
memberskonopa30-Mar-06 9:07 
GeneralUse in vm Pin
pietro7719-May-04 22:00
memberpietro7719-May-04 22:00 
GeneralUse in vm Pin
pietro7719-May-04 0:12
memberpietro7719-May-04 0:12 
GeneralRe: Use in vm Pin
Iain Clarke19-May-04 1:10
memberIain Clarke19-May-04 1:10 
GeneralRe: Use in vm Pin
Iain Clarke19-May-04 1:31
memberIain Clarke19-May-04 1:31 
GeneralThat first 5 *wasn't* by me! Pin
Iain Clarke11-May-04 22:37
memberIain Clarke11-May-04 22:37 

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 | Cookies | Terms of Use | Mobile
Web02-2016 | 2.8.180618.1 | Last Updated 11 May 2004
Article Copyright 2004 by Iain Clarke, Warrior Programmer
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid