Virtual ListBox derived from CListBox

Posted on 1997-06-07
Last Modified: 2013-11-20
I want to create a Virtual Listbox Class derived from the CListBox Class. In this class I want to be able to browse a large database virtually. I don't want to use the vlist example from Microsoft. I would like to see if posible an example on how I should handle the scrolling as I add new items to the listbox and remove those that are no longer displayed.

Thank you.
Question by:HVAZQUEZ
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2

Expert Comment

ID: 1302009
Try using the CListCtrl instead. This has added features of showing imagelists , horizontal scrolling , headers etc, which would require owner-draw programming for a Listbox. CListCtrl is an answer to your problems.

Author Comment

ID: 1302010
I already now this. But I want to use the Listbox because I need to make it generic to be used in both VC++ 1.52 and VC++ 4.2.


Accepted Solution

umesh053097 earned 120 total points
ID: 1302011
The soln. to this problem is complex and not easily explained.Here is what i would try.First of all use an Owner drawn listbox so that you can have about 16K entries. Now your listbox is a window to 16K records in your database. The problem arises when the number of entries exceeds 16K which is where you have to provide the virtual behaviour. The key to this lies in 2 things.1> Maintaining a  virtual origin.2> Manipulating the scrollbar position so that the user knows wwhen he has reached the end of the database.For ex. if you have 16K + 10 elements and the user wants to see the last 10 elements you would 1> Reset the origin to 102> Invalidate Lisbox.3> Update Window.The drawitem for each row of the litbox used the formulaorigin + itemdata(passed in DrawItemStruct)How to scroll is also something you have to fig. out.I am not sure about the 16K fig. In Win95 it is larger. However you can set it to even lesser number.All the best.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Author Comment

ID: 1302012
I would have liked to have seen some code but the answer is enough to give me a clear path to my solution.

Thank you,

Hector Vazquez

Author Comment

ID: 1302013
I would have liked to have seen some code but the answer is enough to give me a clear path to my solution.

Thank you,

Hector Vazquez

Expert Comment

ID: 1302014
Your most welcome Hector.I am unable to give you any code because I have not come across this problem myself. And as I had written earlier, it is a bit complex and would take a couple of days to come up with a reasonably good solution.

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MFC Dialog 9 52
Question regarding Copy/Paste 16 98
My project did see openJDK that I installed. What could be the problem 7 161
x-bar in Google Sheets 2 96
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question