Click here to Skip to main content
15,891,828 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C++
// OnInitDialog() of my VC++ program
// I setup a listctrl variable like this:

<pre>::ZeroMemory(&item, sizeof(item));
	item.mask = LVIF_TEXT;
	item.pszText = _T("");
	item.iItem = 0;
	item.iImage = 0;
	item.state = 0

DWORD dwEXStyle = m_ListCtrl.GetExtendedStyle();
	m_ListCtrl.SetExtendedStyle(dwEXStyle | LVS_EX_GRIDLINES | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER);
	
// And to move data to listctrl,I made one new row by InsertItem.
::ZeroMemory(&item, sizeof(item));

	item.mask = LVIF_TEXT;
	item.pszText = _T("");
	item.iItem = i;
	item.iImage = 0;
	item.state = 0;// LVIS_SELECTED | LVIS_FOCUSED;


	int NewRow = m_List_.InsertItem(&item);

// Next, I move data value to each column by SetItemText like this:
	/* SEQ */
	strTmp = logseq;
	m_ListCtrl.SetItemText(i, 0, strTmp);

        /* Next columns */
        ...
        ...
        ...
// At last, I focus newrow by EnsureVisible...

	m_ListCtrl.EnsureVisible(NewRow, TRUE);

// And every 1000 row, I clear all screen by DeleteAllItems() 
if (row_count_ % 1000 == 0)
	{
		m_ListCtrl.DeleteAllItems();
		row_count_ = 0;
	}



/* In the first time, for a while of the beginning, moving data to screen show good scrolling.
But after passing any of long time, the rows of ListCtrl have broken lines and chars, So no one can distinguish the data of screen..

I don't know why and how the bug of this error.

Please let me know the method to fix it.

Thank you in advance */

What I have tried:

More than 1 week wasted for this problem.
Posted
Comments
Richard MacCutchan 28-Jul-17 5:28am    
You need to stop your View from being updated while you build the ListCtrl. And why create all the entries with blank text and then go through them all a second time setting the text items? That just makes it more likely to get in a mess trying to update the view. Also, with more than 1000 rows you are making it more difficult for the view refresh to keep up when you are sending text as fast as possible into each item. You may like to consider using a virtual ListCtrl and keeping all the thousands of items in memory ready to be displayed when the view scrolls.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900