SnapShot ComboBox

In many cases, a SnapShot(quick) ComboBox control is useful. When number of items exceds 10,000 items, filling a combobox will take a long time, and in that case a QComboBox is welcome. I am working in Windows CE environment, where the speed is a real requirement.

It's a very easy to understand how this control works. The idea is to load only items that I need. When, nothing is happen in the system, one of the alive QComboBox controls, will take this time as useful, and it will load a number of lines for each alive controls, and so on. If you want to find more details, you can feel free ask me, or to study the given implementation of CQComboBox class.

For using this kind of ComboBox, user must provide two mandatory things:

  1. A function Line, which must return the line from a given position.
  2. The count of lines in the QComboBox control.
  3. If the control must provide a "search for" option, the user must provide a function LinePartial that will return the position of the line which starts with a given text string.

How user can use this control?

  1. First step is to put a custom control with "QComboBox" as class name in resource editor. If user wants to create the control dynamically, he can call the CreateEx function with class name "QComboBox", and with others required parameters to create a normal window.
  2. The second step is to allocate member variables into the dialog class of CQComboBox type for each custom controls put in editor resource.
  3. The user must to call the constructor of each CQComboBox member variable, with three arguments. The first indicates the Line function; the second, the LinePartial function, and the third contains user data.

    The "Line" function has the following type:
      LPCTSTR LineFunction(int iLine, LPARAM& lParamItem, LPARAM lParam = 0); 
    

    where iLine represent position of required line , lParamItem represents a user data for each line, and lParam is passed to this function with same value set in the third argument of CQComboBox constructor.

    "LinePartial" function has the following type:

      int LinePartialFunction (LPCTSTR lpszItemPartial, LPARAM lParam = 0); 
    

    where lpszItemPartial is the string to looking for in lines, lParam has the same specification like in "Line" function.

  4. In OnInitDialog, or OnInitialUpdate(from case to case), user must to call SubclassDlgItem, or CreateEx function, to subclass(create) all needed custom controls. The next pass is to call SetCountItems of CQComboBox, for each QComboBox control. This function needs for updating the vertical scroll bar QComboBox object. If this function, is not called, then vertical scroll bar in dropped listbox, will not exists, but you can access to all lines, throw keys left, down, pgup, pgdn,...

How user will know when something is happening in the QComboBox control?

There exist three important (for me) messages that parent of QCOmboBox object will receive. Parent window will receive QCBN_SELCHANGE registered message when the user changes the selection in control. The wParam parameter will contain the ID identifier of combo box, which sends the message, lParam will retrieve the handle of same window. To find the value of a registered message feel free to call RegisterWindowMessage. If the message is already registered, the function will return a UINT value of message.

Also, the parent window of QComboBox will receive the QCBN_LOADING, and QCBN_LOADED messages. These messages are received before and after the QComboBox control load a number of items. wParam parameter, in that case, will have the handle to qcombobox control. To find which are the items that will be loaded, the lParam parameters passed by these messages, in the QCBN_LOADING message case, represents the first line that will be loaded, and in QCBN_LOADED message, the count of loaded lines.

QSnapLoader class is a general class for load snippet of lines. This implements a double linked list for manages all loaded lines. Any improvments to this classes is welcomed.

Download demo project - 36 KB

Download source - 10 KB



Comments

  • WM_KICKIDLE is never send

    Posted by Legacy on 11/06/2000 12:00am

    Originally posted by: Ralin Chimev

    WM_KICK idle is never send to a formview.

    Reply
  • 10,000 items , TOO MANY!

    Posted by Legacy on 10/24/1998 12:00am

    Originally posted by: Todd Brannam

    Having 10,000 items in a combo box is BAD UI! you should consider a different interface.

    Reply
Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Live Event Date: November 6, 2014 @ 2:00 p.m. ET / 11:00 a.m. PT Are you wanting to target two or more platforms such as iOS, Android, and/or Windows? You are not alone. 90% of enterprises today are targeting two or more platforms. Attend this eSeminar to discover how mobile app developers can rely on one IDE to create applications across platforms and approaches (web, native, and/or hybrid), saving time, money, and effort and introducing apps to market faster. You'll learn the trade-offs for gaining long …

  • Live Event Date: October 29, 2014 @ 11:00 a.m. ET / 8:00 a.m. PT Are you interested in building a cognitive application using the power of IBM Watson? Need a platform that provides speed and ease for rapidly deploying this application? Join Chris Madison, Watson Solution Architect, as he walks through the process of building a Watson powered application on IBM Bluemix. Chris will talk about the new Watson Services just released on IBM bluemix, but more importantly he will do a step by step cognitive …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds