Reputation: 341
Hello friends! I want to make a dictionary like Microsoft Encarta English Dictionary using the native C++ WIN32 API. My database is Microsoft Office Access 2007 format database which has 21,364 records (filled with vocabularies and their meanings). I want to add the vocabularies into a list box control using the "CreateWindow
" function with the "listbox
" window class name as fast as possible so that no one will get annoyed of waiting.
I am very much interested in the OLE DB database connection method as it is said to be the fastest of all other methods. I followed the OLE DB tutorial as given in this link: http://msdn.microsoft.com/en-us/library/office/ff965871%28v=office.14%29. Following the tutorial, I successfully connected to the database of Microsoft Office Access 2007 format having 21,364 records and added the vocabularies into the list box using the "SendMessage
" function with the "LB_ADDSTRING
" message type within a "for
" loop.
However, I feel that adding the 21,364 records into the list box using the "for
" loop takes a bit longer than someone could patiently wait. On the contrary, I am sure the Microsoft Encarta English Dictionary should be having millions of vocabularies and they all added into a list box so fast that someone would burst out with joy!
Can anyone please kindly tell me, guide me, show me with code examples how to speed up my adding huge amount of Microsoft Office Access 2007 database records into a list box using the native C++ WIN32 API? I shall be very thankful!
Upvotes: 0
Views: 249
Reputation: 490278
There are a few steps you can take when/if you want to add a lot of records to a list box quickly.
For ~20,000 items, the first will probably suffice. Doing a quick check of inserting 20,000 items into a list box with sorting turned off, I'm getting about a half second without doing any more than that, so while there is a pause while it's filled, it's not enough to be annoying unless it happens frequently (i.e., you destroy and re-fill the listbox frequently).
At the same time, I do feel obliged to point out that a listbox containing 20,000 items is never likely to qualify as a really great design. You probably want/need to do something to narrow down how much of that you really display to the user at any given time.
Upvotes: 3