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 ?
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 ?
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.