Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CListCtrl - realtime scrolling

CListCtrl - realtime scrolling

Scheduled Pinned Locked Moved C / C++ / MFC
databasequestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lost User
    wrote on last edited by
    #1

    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); } } }

    M 1 Reply Last reply
    0
    • L Lost User

      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); } } }

      M Offline
      M Offline
      Mike Dunn
      wrote on last edited by
      #2

      Do you really have to redraw every item? If not, call Invalidate() on the list control to have it repaint the visible portions.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups