CListCtrl - realtime scrolling
-
I am using the ClistCtrl control to display packet traffic on a serial I/O line. I use Scroll() so the most recent packet appers on the bottom of the list. Once I reach an upper limit I call DeleteItem(0) to keep the total rows at a fixed limit. The code shown below works but once the upper limit is reached the CListCtrl scrolls the header off the screen which is weird. The only way I've been able to get around this is to call RedrawItems() but this causes way to much flicker. I'm I missing something? I used to do this with ListBox() without any problems. Oh there also seems to be an upper limit to how many characters I can put into a cell of about 200 chars and if I exceed this the cpu activity shoots to 99 and locks the app - fyi. void CCListCtrlAdv::SetColumnData(CStringListEx& strlist, int nIndex) { if(strlist.GetCount()) { if(GetItemCount() >= m_nMaxItemCount) { DeleteItem(INDEX_0); RedrawItems(0, GetItemCount()); // causes to much flicker } int column = 0; POSITION pos = strlist.GetHeadPosition(); if(nIndex == INVALID) { nIndex = GetItemCount(); } while(pos) { CString& str = strlist.GetNext(pos); if(column == COLUMN_0) { SET_LV_ITEM(lvi); lvi.mask = LVIF_TEXT; lvi.iItem = nIndex; lvi.pszText = str.GetBuffer(0); lvi.cchTextMax = str.GetLength(); InsertItem(&lvi); } else { SetItemText(nIndex, column, str.GetBuffer(0)); } column++; } if(nIndex > GetCountPerPage()-1) { CRect rect; GetItemRect(GetTopIndex(), rect, LVIR_BOUNDS); CSize size; size.cx = 0; size.cy = rect.Height(); Scroll(size); } } }
-
I am using the ClistCtrl control to display packet traffic on a serial I/O line. I use Scroll() so the most recent packet appers on the bottom of the list. Once I reach an upper limit I call DeleteItem(0) to keep the total rows at a fixed limit. The code shown below works but once the upper limit is reached the CListCtrl scrolls the header off the screen which is weird. The only way I've been able to get around this is to call RedrawItems() but this causes way to much flicker. I'm I missing something? I used to do this with ListBox() without any problems. Oh there also seems to be an upper limit to how many characters I can put into a cell of about 200 chars and if I exceed this the cpu activity shoots to 99 and locks the app - fyi. void CCListCtrlAdv::SetColumnData(CStringListEx& strlist, int nIndex) { if(strlist.GetCount()) { if(GetItemCount() >= m_nMaxItemCount) { DeleteItem(INDEX_0); RedrawItems(0, GetItemCount()); // causes to much flicker } int column = 0; POSITION pos = strlist.GetHeadPosition(); if(nIndex == INVALID) { nIndex = GetItemCount(); } while(pos) { CString& str = strlist.GetNext(pos); if(column == COLUMN_0) { SET_LV_ITEM(lvi); lvi.mask = LVIF_TEXT; lvi.iItem = nIndex; lvi.pszText = str.GetBuffer(0); lvi.cchTextMax = str.GetLength(); InsertItem(&lvi); } else { SetItemText(nIndex, column, str.GetBuffer(0)); } column++; } if(nIndex > GetCountPerPage()-1) { CRect rect; GetItemRect(GetTopIndex(), rect, LVIR_BOUNDS); CSize size; size.cx = 0; size.cy = rect.Height(); Scroll(size); } } }