Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CListCtrl performance problem

Status
Not open for further replies.

cdraycott

Programmer
May 24, 2001
57
GB
I am currently populating a CListCtrl up to a limit of say 100 items.
If more items come in then i want to get rid of the first item in the clistctrl and add the new item to the end, thus producing a rolling list.
The problem is, when the list is scrolling it uses a great deal of processor time and I would like to be able to access other menu items and move the mouse etc but am unable when it is scrolling.

Is there another way of getting rid of the first item and adding a new item without it performing the scrolling?
 
I can't uderstand why do you need it? Just fill the list. When you want to scroll send scrolling messages. Every toher things will be performed automatically. John Fill
1c.bmp


ivfmd@mail.md
 
Thats the whole problem. It is scrolling the items automatically and whilst it is doing it, the processor is tied up.

Say there are max 20 items.
It fills as normal for first 20.
Then it deletes item 0, thus shifting all items up one.
Then add one to the end.
Theses items are being added pretty quickly and you can imagine that it is constantly scrolling.
This means i cant do anything else in the app.
 
Thanks John.

These List items represent Events from a COM Server and they come in at a fast rate. If i did not put a limit on the list it would be too big for the user to see and the memory for my application would increase and increase until it ran out and then it would crash.

So your opinion that i should not put a limit on the list is not a good one.

Thanks for responding though
 
I Suppose you use the CListCtrl trough a CListView class.
The ClistView class IS-A CView class which IS-A CWnd class.

Now the CWnd class has some member functions named:
- SetScrollInfo
- SetScrollPos
- SetScrollRange
- EnableScrollBarCtrl

Try to manipulate tthese functions somehow to overide the default behaviour of the CListView object

Hope this helps,
s-)

Blessed is he who in the name of justice and good will, shepards the week through the valley of darknees...
 
You could fill items with a snapshot of data, but in memory store the dinamically generated data. Every when user want to update the list, refresh it. It means delete all items and put the new ones. John Fill
1c.bmp


ivfmd@mail.md
 
Hi Guys I think I may have solved the problem.
I thought I would let you know for the purposes of the Forum.

What I have done is to Add the items as normal up to the limit i set.
Then when it hits the limit I do the following, an example is best to show:

20 is the limit
New item to be added.
check GetItemCount() >= limit
if so
for (int i = 1; i<=numitems-1; i++
//get text of first Column in second item
CString strText = Lst.GetItemText(i,0);
//set this to the text of the first item
Lst.SetItemText(i-1,0,strText);
//now do the same for the next 15 columns
for (int j=1; j<16; j++)
{
CString strText2 = Lst.GetItemText(i,j);
Lst.SetItemText(i-1,j,strText2);
}

This seems to work ok for me.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top