Take the 2-minute tour ×

Is there a way, either natively supported by CListCtrl, or with some coding technique, to update a chunk of data in a virtual-list-mode CListCtrl instead of one at a time?

By default, when the list requires a data for a cell, we handle it via LVS_GETDISPINFO. If I have say 8x8 (64) cells visible and constantly updating, it's basically calling the handler to LVS_GETDISPINFO 64 times. This is fine and expected behavior, but I believe there is a small overhead in calling this function repeatedly, as opposed to just doing it in a for-loop for all the 64 cells. And this is a problem to me because my control constantly updates all the 64 cells (imagine something like a TCP packet trace).

CListCtrl supports caching of course (although useless in my situation), but again I feel there is overhead in calling the LVS_GETDISPINFO handler over and over again. A simple example would be, say to determine if my pointer to the database is valid (not null) before obtaining the data ... in essence this line of code is called 64 times, when I could have done it just 1 time, then for-loop the pointer to get the data of my 64 cells. Also, the pointer is just a simple example, there is more that I am doing (which cannot be avoided) that I won't explain since it requires code.

As time is of the essence, I can't go back to re-write my own list ctrl that is more efficient, as it takes time to duplicate the other benefits of CListCtrl that I am enjoying by inheriting it directly. The only issue now is speed. If there is a way, say something like a handler that passes in a null-terminated array of cells to update so that we can update this in bulk in just one function, that would be great.

Or maybe is it possible to know what cells are pending update in LVS_GETDISPINFO, so that, if possible, I update all the cells, and validate the entire update to stop getting LVS_GETDISPINFO?

Any ideas? Thanks in advance.

share|improve this question
Maybe you can just use SetRedraw(FALSE) than fill in your list and call SetRedraw(TRUE) to show all the results at once. It is hard to justify the performance hit though as the default list does give you a clean implementation. If you want to do the bulk thing, you will be adding more complexity of which row and column has changed which will be hard to maintain and look after. –  zadane Jan 4 '12 at 1:13
Yup, I am using the SetRedraw method to eliminate flickering. Well, I was hoping the bulk-method will only be used when a "full visible area" update is needed (which is basically true all the time for my case since it is constantly updating all the cells), so we don't have the complexity on managing the which rows and column to change. Or in other words, it will always be a continuous range of rows. Anyway, I agree with you that the default is the cleanest implementation. I guess CListCtrl is just not meant for fast-updating data. I'll continue to ponder somemore before giving up. –  Ryuu Jan 4 '12 at 1:58
add comment

Your Answer



Browse other questions tagged or ask your own question.