Most of the features of all grid cells are implemented in the basic CExtGridCell
class, including built-in support for a check box, an image, text, a drop-down button, an up-down button and an ellipsis button. The CExtGridCellCheckBox
class just provides a simpler API for working with a check box cell. The CExtGridCellComboBox
class provides an API similar to that in the combo box control and it manages a collection of strings. Some other classes provide alternative data for editing and alternative in-place editor windows instead of a simple single line edit control provided by the CExtGridCell
class. You can use any cell class in outer header areas. The only difference between outer header cells and data cells is that they optionally should store column minimal/maximal/current widths (current width values in pixels and/or double
values for proportional column resizing) and row minimal/maximal/current heights (current height values in pixels and/or double
values for proportional row resizing) when your grid window uses variable/resizable columns and/or rows. The CExtGridCellHeader
class implements a grid cell which is a simple string cell class with the ability to store row height or column width values called extents. To make any grid cell able to store extents in pixels, you should apply the CExtGCE
template decorator class to it. To make any grid cell able to store proportional extents, you should apply the CExtGCP
template decorator class to it. There are several other template decorator classes for extending capabilities of grid cells, but they are not related to your question. For example, the CExtGridCellHeader
class is declared as follows:
class CExtGridCellHeader
: public CExtGCF < CExtGCC < CExtGCP < CExtGCE < CExtGridCellStringDM > > > >
{
. . .
As you can see, both the
CExtGCE
and
CExtGCP
template classes are present in it. You can create the same class based on the check box cell and use it in header areas:
class CYourCheckBoxCellForOuterHeaderArea : public CExtGCP < CExtGCE < CExtGridCellCheckBox > >
{
public:
DECLARE_SERIAL( CYourCheckBoxCellForOuterHeaderArea );
IMPLEMENT_ExtGridCell_Clone( CYourCheckBoxCellForOuterHeaderArea, CExtGCP < CExtGCE < CExtGridCellCheckBox > > );
CYourCheckBoxCellForOuterHeaderArea( CExtGridDataProvider * pDataProvider = NULL )
: public CExtGridCellCheckBox( pDataProvider )
{
}
CYourCheckBoxCellForOuterHeaderArea( const CExtGridCell & other )
: public CExtGridCellCheckBox( other )
{
}
virtual ~CYourCheckBoxCellForOuterHeaderArea()
{
}
};
// The following line of code should be placed at the beginning of .CPP file before definition
// of the MFC debug version of the new operator:
IMPLEMENT_SERIAL( CYourCheckBoxCellForOuterHeaderArea, CExtGridCellCheckBox, VERSIONABLE_SCHEMA|1 );
To instantiate this check box class in the header areas of the
CExtGridWnd
control you should simply use it in the invocation of the
CExtGridWnd::GridCellGet***()
methods:
CExtGridWnd * pGrid = . . .
CExtGridCell * pCell = pGrid->GridCellGetOuterAtTop( nColNo, nRowNo, RUNTIME_CLASS( CYourCheckBoxCellForOuterHeaderArea ) );
if( pCell != NULL )
{
CYourCheckBoxCellForOuterHeaderArea * pYourCell =
STATIC_DOWNCAST( CYourCheckBoxCellForOuterHeaderArea, pCell );
. . .
}