Professional UI Solutions
Site Map   /  Register
 
 

Forum

Please Log In to post a new message or reply to an existing one. If you are not registered, please register.

NOTE: Some forums may be read-only if you are not currently subscribed to our technical support services.

Forums » Prof-UIS Tech Support » ReportColumnRegister is not returning a pointer to type I specify Collapse All
Subject Author Date
David Skok Feb 20, 2007 - 12:50 PM

I derive a new type from CExtReportGridColumn as follows:

class DxReportGridColumn : public CExtReportGridColumn {
DECLARE_DYNCREATE( DxReportGridColumn);

CRuntimeClass* pCellClass;
public:
DxReportGridColumn(CExtGridDataProvider *pDP = 0) : CExtReportGridColumn(pDP) { pCellClass = 0; }
void SetDefaultCellColumnClass( CRuntimeClass *pClass ) { pCellClass = pClass; }
CRuntimeClass* GetDefaultCellColumnClass( void ) { return pCellClass; }
};

In the ReportGrid I call:

DxReportGridColumn * pRGC = NULL;

pRGC = (DxReportGridColumn *) ReportColumnRegister( "ColumnName", "CategoryName", true,
false, RUNTIME_CLASS(DxReportGridColumn) );

The type of pRGC returned is always CExtReportGridColumn!! The constructor for my type is called so it is actually created however the type is downcast back to CExtReportGridColumn somewhere before it is returned by ReportColumnRegister. I can see this when I step into ReportColumnRegister code.

Dave



Suhai Gyorgy Feb 21, 2007 - 3:02 AM

CExtReportGridColumn is derived from CExtGridCellHeader, which is derived from CExtGridCell, so when deriving a new class from CExtReportGridColumn, you need to do all steps required for the deriving of a new cell class. You need to use

DECLARE_SERIAL( DxReportGridColumn ); 
IMPLEMENT_ExtGridCell_Clone( DxReportGridColumn, CExtReportGridColumn);
instead of DECLARE_DYNCREATE(DxReportGridColumn);, and also you need to use IMPLEMENT_SERIAL instead of IMPLEMENT_DYNCREATE on the very top of the .cpp file, like this:
IMPLEMENT_SERIAL( DxReportGridColumn, CExtReportGridColumn, VERSIONABLE_SCHEMA|1 ); // add this one line
 
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

Technical Support Feb 21, 2007 - 3:12 AM

In addition we would like to add you may also need to implement the CExtGridCell::Assign() and CExtGridCell::Serialize() virtual methods if your DxReportGridColumn class has some data properties.

PS You can use any grid cell class as an example of IMPLEMENT_ExtGridCell_Clone( DxReportGridColumn, CExtReportGridColumn ); declaration.