In borland Delphi or C++ Builder, You can speed up the insertion process of items into a list view by making the listview stop responding to the WM_PAINT or a message of that sort, temporarily. i was wondering if any of you guys know how i could do that.

btw, the method is called BeginUpdate. E.g : ListView1.Items.BeginUpdate and then ListView1.Items.EndUpdate
Posted on 2006-06-17 02:55:51 by XCHG
If you know how many items you'll be adding, you can start by sending a LVM_SETITEMCOUNT - this will keep the listview from constantly reallocating, and will speed things up a bit. Even if you don't know the exact number, you could send an approximation.

Then, send a WM_SETREDRAW messages to disable updating, add all your items, and send a WM_SETREDRAW again, to enable updating.

If you need a *lot* of items in a listview, consider using a virtual listview instead. It's not difficult to code, and can be a LOT faster.
Posted on 2006-06-17 06:22:16 by f0dder
To answer the question, you need to SUBCLASS the control, and point its WndProc at a 'dummy wndproc' which 'suppresses unwanted WMs' - then add your items, then restore the original wndproc.

I've never heard of this being used to speed up the adding of elements to a listview, but I'm no great win gui coder.
Posted on 2006-06-17 13:56:02 by Homer
Homer, that sounds like quite the roundabout way of doing it when WM_SETREDRAW ought to work :)
Posted on 2006-06-17 15:24:59 by f0dder
Both of them worked, thanks a million guys
Posted on 2006-06-22 09:12:51 by XCHG
If you have a very large number of items to use in your listview you should be using a virtual listview. The virtual listview allows you to only be concerned with what is actually being displayed and to generate the data only when needed. It is always fast and does not have the memory load of a normal listview with thousands of items. The hex viewer of WinExplorer uses a virtual listview to display files in hex.

Donkey
Posted on 2006-06-24 06:51:39 by donkey
Alright i think i finally got a hold of this. thanks to you guys. appreciations
Posted on 2006-07-01 03:39:43 by XCHG