I have started writing a Grid control derived from CWnd. I am using VC++ 6 with SP5
The architecture is based on Chris Maunder's MFC Grid Control from CodeProject.com. I have used CTypedPtrArray to allocate memory for Grid cells. I have also used a Memory device context in Paint to stop flicker. The code works fine till I load 500 items in the grid. Beyond that I get a debug assertion in my Paint procedure in this line,
CBitmap *oldBitmap = memDC.SelectObject(&bm); I checked during debug and found out that memDC becomes NULL. I tried not using memDC, but the problem still continues..this time with the dc of CPaintDC itself. The Release version just blanks out the entire screen. I am not able to understand, please help.
Here are the relevant portions in the code:
BOOL CGridCtrl::OnEraseBkgnd(CDC* pDC)
CBitmap *oldBitmap = memDC.SelectObject(&bm);
//Erase the background here
//Draw the Grid