How to add blocks of items to a list view control? When i add them one by one, the list view control repaints itself each time and the whole parent window stalls for about half a second. How to make listview repaint itself only when all the necessary items have been added?
Posted on 2004-03-09 04:17:52 by Vaxon
You can try this code:
invoke SendMessage, hWndList, WM_SETREDRAW, FALSE, 0
; Add a block of items to list
....
invoke SendMessage, hWndList, WM_SETREDRAW, TRUE, 0
Hope it will work
TQN
Posted on 2004-03-09 05:17:06 by TQN
Just use LockWindowUpdate:

invoke LockWindowUpdate,[hListview]

;add items
invoke LockWindowUpdate,NULL
Posted on 2004-03-09 07:21:15 by donkey
I was looking at MSDN about LockWindowUpdate, mainly because I havent' heard of that one ... and I was wondering why there is a boolean param.

The LockWindowUpdate function disables or enables drawing

in the specified window. Only one window can be locked at a time.

BOOL LockWindowUpdate(
HWND hWndLock // handle to window
);
Parameters
hWndLock
[in] Specifies the window in which drawing will be disabled. If this
parameter is NULL, drawing in the locked window is enabled.


It seems as though this really isn't needed.
Posted on 2004-03-09 08:03:49 by gorshing
Yup, your right.

I have used it but not often, I was doing it from memory.
Posted on 2004-03-09 08:13:32 by donkey
If you're adding a whole block of items, you should also use the LVM_SETITEMCOUNT message - when adding (not populating initially), you should LVM_GETITEMCOUNT, add amount of new items, and send LVM_SETITEMCOUNT.

I personally prefer WM_SETREDRAW to LockWindowUpdate, because "Only one window can be locked at a time."

If you need a *lot* of items in a listview, look into using listviews in the virtual mode. This is much faster than having windows manage the data internally, you can feel this especially on additems/destroy, and especially on Win9x.
Posted on 2004-03-09 08:32:50 by f0dder