Hi,
I have some problems when I refresh my CCacheableGridBaseWnd derived class based on this sample. This happens when I call SiwFireCacheChanging with a vertical scrolling position different of 0 ; the data doesn’t correspond to its row and some appear twice.
Here’s my code :
BoardGrid.h :
class CBoardGrid : public CCacheableGridBaseWnd
{
...
}
BoardGrid.cpp :
void CBoardGrid::OnCacheHeaderCell(LONG nRealHeaderColNo,
CExtGridDataProvider * pCacheDataStorage,
LONG nCacheDataStorageColNo,
LONG nCacheDataStorageRowNo)
{
...
}
void CBoardGrid::OnCacheDataCell(LONG nRealRangeColNo,
LONG nRealRangeRowNo,
CExtGridDataProvider * pCacheDataStorage,
LONG nCacheDataStorageColNo,
LONG nCacheDataStorageRowNo)
{
ASSERT_VALID(this);
ASSERT_VALID(pCacheDataStorage);
if (nRealRangeRowNo >= m_pBoardsQueue->size() ||
nRealRangeRowNo >= m_pSolutionsQueue->size())
{
pCacheDataStorage->CellRangeSet(nCacheDataStorageColNo,
nCacheDataStorageRowNo, 1, 1, NULL);
return;
}
int nBrdNumber = (*m_pBoardsQueue)[nRealRangeRowNo].GetBoardNumber();
CExtGridCellString cellData(pCacheDataStorage);
cellData.ModifyStyle(__EGCS_READ_ONLY);
cellData.BackColorSet(CExtGridCell::__ECS_ALL,
(nBrdNumber%2)?GRID_LINE_EVEN_COLOR:GRID_LINE_ODD_COLOR);
cellData.TextColorSet(CExtGridCell::__ECS_ALL,
(!(nBrdNumber%2))?GRID_TEXT_EVEN_COLOR:GRID_TEXT_ODD_COLOR);
CExtSafeString strDataCellText;
strDataCellText.Format("%d", nBrdNumber);
cellData.TextSet(LPCTSTR(strDataCellText));
pCacheDataStorage->CellRangeSet(nCacheDataStorageColNo,
nCacheDataStorageRowNo, 1, 1, &cellData);
}
where m_pBoardsQueue is a fixed size queue.
And this is how it works to update the grid : (SDI App)
I have a timer in the CMainFrame that calls UpdateAllViews from the active document
(in which the queue is declared). I also have a CFormview-derived view that contains
the grid and an overloaded member OnUpdate that calls SiwFireCacheChanging().
MainFrm.cpp :
void CMainFrame::OnTimer(UINT_PTR nIDEvent)
{
switch(nIDEvent)
{
...
case IDT_REFRESHING_RATE :
{
COptiMainDoc *pDoc = (COptiMainDoc*)GetDocBeforeDisplay();
if (m_pCommGUI == NULL || pDoc == NULL || !m_bCommInitialized)
{
break;
}
pDoc->UpdateAllViews(NULL, HVU_BOARD);
}
break;
default :
break;
}
CVABMainFrame::OnTimer(nIDEvent);
}
BoardBaseView.cpp :
void CBoardBaseView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
if (!(lHint & HVU_BOARD) && lHint != HVU_ALL)
{
return;
}
m_gridBoardsQueue.SiwFireCacheChanging();
CExtWA<CExtWS<CExtAFV<CFormView> > >::OnUpdate(pSender, lHint, pHint);
}
Thanks in advance