
Introduction
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();
Notes
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.
Acknowledgements
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.
History
- 2004 May 11th - First released into the wild.