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 General Discussion » How do I create a subclass of CExtGridCellComboBox Collapse All
Subject Author Date
Douglas Hoppes Aug 20, 2009 - 11:29 AM

Hi all,

Hope that this is simple. I would like to have my own GridCellComboBox. In my current code, I have:

-------------------------------------------------
.h file:
    // Inner Classes
    class CMarkerComboBox : public CExtGridCellComboBox
    {
    public:
        // Constructors/Destructor
        CMarkerComboBox(CExtGridDataProvider *pDataProvider = NULL);
        ~CMarkerComboBox();

        // Methods
        virtual bool OnPopupListBoxItemDraw(CExtPopupInplaceListBox & wndListBox, CExtGridCell::TrackCellStateInfo_t & _tcsi,
LPDRAWITEMSTRUCT pDIS);
    };

.cpp file:
CGridControl::CMarkerComboBox::CMarkerComboBox(CExtGridDataProvider * pDataProvider /*= NULL */)
:CExtGridCellComboBox(pDataProvider)
{
AfxMessageBox("Here I am: Constructor");
}

CmbfGridControl::CMarkerComboBox::~CMarkerComboBox()
{
AfxMessageBox("Here I am: Destructor");
}

bool CmbfGridControl::CMarkerComboBox::OnPopupListBoxItemDraw(CExtPopupInplaceListBox & wndListBox,
     CExtGridCell::TrackCellStateInfo_t & _tcsi,
     LPDRAWITEMSTRUCT pDIs)
{
AfxMessageBox("Here I am: PopupListBoxItemDraw");
     return true;
}
-------------------------------------------------

To create the MarkerComboBox, I use:

CMarkerComboBox * pCellComboBox = STATIC_DOWNCAST(CMarkerComboBox,
                     GridCellGet(i, lCurrentRow, 0, 0,
                         RUNTIME_CLASS(CMarkerComboBox)));

When running the application, I put a couple of breakpoints in the CMarkerComboBox, but none of the breakpoints are hit. So, obviously, I must not be creating my sub-class correctly.

Any help is greatly appreciated.

Doug

Technical Support Aug 21, 2009 - 4:01 AM

You forgot to add run-time type information and data provider memory management features to your grid cell class. The grid cell classes require the DECLARE_SERIAL, IMPLEMENT_SERIAL and IMPLEMENT_ExtGridCell_Clone macroses. The DECLARE_SERAIL and IMPLEMENT_ExtGridCell_Clone macroses should be inserted into the class declaration:

class CMarkerComboBox : public CExtGridCellComboBox
{
public:
      DECLARE_SERIAL( CMarkerComboBox);
      IMPLEMENT_ExtGridCell_Clone( CMarkerComboBox, CExtGridCellComboBox );

      // Constructors/Destructor
      CMarkerComboBox( CExtGridDataProvider *pDataProvider = NULL );
      ~CMarkerComboBox();

      // Methods
      virtual bool OnPopupListBoxItemDraw( CExtPopupInplaceListBox & wndListBox, CExtGridCell::TrackCellStateInfo_t & _tcsi, LPDRAWITEMSTRUCT pDIS );
};

The IMPLEMENT_SERIAL line of code should be inserted at the very beginning of some .CPP file in your project and you should put it before declaration of the MFC’s debug version of C++ new operator:
IMPLEMENT_SERIAL( CExtGridCellFontFaceName, CExtGridCellComboBox, VERSIONABLE_SCHEMA|1 );

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif