Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

CListCtrl performances

0 views
Skip to first unread message

Jeff Delaney

unread,
Feb 14, 1997, 3:00:00 AM2/14/97
to

I found the CListCtrl to be slow as well for large number of items.
However, a couple ways that sped up the process for me were:

1. Set

pList->SetRedraw (FALSE);

before inserting, and then call

pList->SetRedraw (TRUE);

after the loop.

2. If your List control is sorted by default. you may want to disable the
sorting as you are adding the items, and then sort the list at the end.

For example the execution of the following code, used to create a list of
5000
items, take around 7 seconds on a Pentium 166 with 32 Megabytes of memory !

m_CtrlList declaration:
----------------------
CListCtrl m_CtrlList;

Code sample:
------------
m_CtrlList.SetItemCount(5000);

for(int i = 0; i < 5000; i++)
{
m_CtrlList.InsertItem(i, LPSTR_TEXTCALLBACK);
}


Is it a way to reduce the execution time of this loop which only set the
item
number of the list ?


Brian Ebarb

unread,
Feb 14, 1997, 3:00:00 AM2/14/97
to

Valerie,

Try calling SetItem instead of InsertItem. Your call to SetItemCount has already reserved space for the items, so InsertItem is not necessary.

Just a thought. Hope it helps!

--
Brian Ebarb
eb...@airmail.net
eb...@novotech.com
beb...@parrent.com

Valerie Julien <v...@es.nce.sita.int> wrote in article <01bc1a7a$9d328f80$3daf...@57.4.25.1.nce.sita.int>...
> Question on CListCtrl MFC class of the VISUAL C++ 4.2 package.
>
> Could somebody explain me why "CListCtrl::InsertItem" method execution time
>   
> is very long ?

Valerie Julien

unread,
Feb 14, 1997, 3:00:00 AM2/14/97
to

Question on CListCtrl MFC class of the VISUAL C++ 4.2 package.

Could somebody explain me why "CListCtrl::InsertItem" method execution time

is very long ?

For example the execution of the following code, used to create a list of
5000
items, take around 7 seconds on a Pentium 166 with 32 Megabytes of memory !

m_CtrlList declaration:
----------------------
CListCtrl m_CtrlList;

Code sample:
------------
m_CtrlList.SetItemCount(5000);

for(int i = 0; i < 5000; i++)
{
m_CtrlList.InsertItem(i, LPSTR_TEXTCALLBACK);
}


Is it a way to reduce the execution time of this loop which only set the
item
number of the list ?

Thanks, JH.

0 new messages