The Virtual List
(Page 1 of 5 )
Good programmers always try to speed up their applications as much as they can, whether it's a simple loop to sort an array of integers or something more complex, like a paint program. Nowadays, more people have started coding, including those who aren't geniuses or wholly dedicated to the task. This means that sometimes efficiency takes a back seat to ease of use. Luckily, there are a few areas in which we can achieve increased efficiency. The list control is one of these.
The object of this article is to introduce you to the concept of the virtual list and you can benefit from it during your daily coding experience. For this, I will create a class list that will contain only a column of characters near a column full of numbers. This will help us to concentrate on the lesson rather than on the task of handling and creating the list control. This will also let me introduce you to all of the advantages of the virtual list.
Before we venture further, let me tell you that this is the second part of my three-part article series related to the secrets of the controls inside MFC. The first chapter appeared here on the Asp Free site under the name of Controls Inside MFC. If you do not have a good understanding of the list controls and their purpose, or how you can customize them, I strongly advise you to read through that previous part.
However, if you already have this knowledge, keep reading. If you've already used the list control in an application where you should have added more than just a couple of items, you've already observed that this could take a long time.
The reason for this can be chalked up to the fact that not only must all of the new text be inserted one by one inside the control's container, but the control also must sort the list, if that is required. When we start to talk about more than 500 items, this can be really time consuming, and you will leave the user in the front of a frozen application with the busy/working pointer turned on.
Furthermore, often you have already stored the data within an internal container of your application. Making sure that this is working in cooperation with the list control is not only time consuming, but you are also saving all the information twice, thus wasting precious memory.
Next: List control without data members >>
More BrainDump Articles
More By Gabor Bernat