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 » Timer + SiwFireCacheChanging() Collapse All
Subject Author Date
Jean-Yves Tremblay Feb 20, 2007 - 9:14 AM

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



Technical Support Feb 22, 2007 - 4:42 AM

Please download a new version of the CacheableGrid sample:

CacheableGrid2.zip

The new version features a Fire! button, which is handled in CDlg::OnFire() where the grid is recached:

void CDlg::OnFire()
{
      m_wndGrid.SiwFireCacheChanging();
}
We used this sample to check the implementation of cacheable grid as careful as possible. We have not found any problems yet. Here is the typical call stack while cashing the data:
CMyGridWnd::OnCacheDataCell(long 0, long 1073047847, CExtGridDataProvider * 0x0012fbb0 {CExtGridDataProviderMemory}, long 0, long 1) line 400
CCacheableGridBaseWnd::_CDP::RsCacheRow(unsigned long 0, unsigned long 1, unsigned char 0) line 242 + 66 bytes
CExtGridDataProviderRecordset::CacheDataStatic(const CExtScrollItemCacheInfo & {...}, const CExtScrollItemCacheInfo & {...}) line 46176 + 38 bytes
CExtGridDataProviderRecordset::CacheData(const CExtScrollItemCacheInfo & {...}, const CExtScrollItemCacheInfo & {...}) line 46432 + 24 bytes
CExtGridWnd::OnSiwCacheChanged(const CExtScrollItemCacheInfo & {...}, const CExtScrollItemCacheInfo & {...}) line 50421 + 21 bytes
CExtScrollItemWnd::_NotifyCacheChanged(long 0, long 0, long 26, long 620, long 1073047847, long 0, long 1999999977, long 24, unsigned char 1, unsigned char 0, unsigned char 0, unsigned char 0) line 5697 + 27 bytes
CExtScrollItemWnd::SiwFireCacheChanging(long -1, long -1, unsigned char 1) line 5441 + 64 bytes
CDlg::OnFire() line 65 + 32 bytes
...
We checked everything the source code relatting to the call stack above and found no problems in re-caching the grid data virtually at any scroll position.

We guess there may be something wrong with data access in your "fixed sized queue". We can check what is the m_pBoardsQueue in your code if you send us your project.