Borland C++-Builder: How to speed up adding of entries in TList-View
Hi Gurus,
this time it is a VCL-component of Borland that drives me crazy:
I have a TListView for displaying the contents of a directory. When I tested my application and used directories with a small or normal amount of entries everything looked fine. then I tried a directory with over 20.000 entries inside. it worked awful. the application took a loooong time to add all entries to the TListView... a very looong time (on a 1,24Ghz Machine).
I optimized the adding-loop as much as possible (three lines of code are not much to optimize );)
but nothing went faster. I set AllocBy to the count of all entries that are added. I set Count to the same value... no effect.:mad:
Ok, next I want to try the adding loop in a single thread (must do this anyway for having a progress-bar running), but I don't think that this improves the performance of the adding-task.
I used a profiler and located the bottle-neck in the windows listbox.
Has anybody an idea how to speed up the adding of entries to a TListBox ? The windows-explorer is pretty fast in displaying directories with much contents. so it must be possible in any way to speed this task up.
Thanx in advance
Juergen
Re: Borland C++-Builder: How to speed up adding of entries in TList-View
Quote:
Originally posted by AlionSolutions
I used a profiler and located the bottle-neck in the windows listbox.
Has anybody an idea how to speed up the adding of entries to a TListBox ? The windows-explorer is pretty fast in displaying directories with much contents. so it must be possible in any way to speed this task up.
Thanx in advance
Juergen
If you used Spy or some other utility, you will find that the Explorer Window is not a ListBox, but a SysTreeView32 and a SysListView32 custom control. Therefore assming that you can get a ListBox to go at the same speed as the Explorer window is not a valid assumption.
There is a message that you can send to a listbox to initialize the memory used to store items. The LB_INITSTORAGE message is used to do this. I don't know what TListBox does, what it encapsulates, or how to use it, but for a true Windows Listbox control, this message can be sent to the listbox window to reserve the memory for the items. I'm assuming that the slow performance is that for each item you're adding, a reallocation of memory is done. If the memory is reserved up front, the allocations don't take place, effectively speeding up the loading of items.
Regards,
Paul McKenzie