Virtual Developer Workshop: Containerized Development with Docker


The current MFC combobox class is insufficient. The pop-down choicelists provided for the application I was writing needed to reduce the amount of typing a user must do. The user is given a list of items from which they can choose any combination of selections. When a selection is chosen from the list, it is placed into the field. This also helps to reduce the amount of spelling errors which can occur. Implementation Specfication This combo box will consist of an edit field with a pop down choicelist. The user can show the choicelist by left-clicking on the down-arrow button or by pressing alt- down or by pressing alt-up. The user can hide the choicelist by clicking in the field or by pressing alt-down or by pressing alt-up. By default, the choicelist is not shown when the field receives focus (eg, mouse click on the field).

When the user types, the field will automatically complete the typing if the substring typed matches the beginning of an item in the choicelist. The selection is completed by the user, if the user hits the right arrow key, or the end key, or types a space and that space is not contained within an item in the choicelist.

The field is subdivided into sections. Each section is delimited by a space. Each section can be autocompleted. There are 2 forms of autocompletion: when typing the first match in the choicelist appears in the field; or after typing some substring (or empty substring) the user can pop-down the choicelist to show only items which match that substring. The choicelist is reset, such that all choices will appear in the next section, when the completion finishes.

Any leading spaces will be removed from the completion match.

The key breakdown is:
right arrow, end key - finish autocompletion
spacebar - finish autocompletion only if space is not contained as part of a substring match
alt-down or alt-up or left-click button - show list of available choices
alt-down or alt-up or left-click in choicelist - hide choicelist, placing selection in field
left-click in field - hide choicelist if shown, cancelling selection

Enforced choicelists are supported. The behavior of an enforced choicelist changes so that the user can not type a value which is not an item in the choicelist. Also, the user can not delete single characters. If the user wishes to change a selection, the old selection must first be deleted, then the new selection can be made.


A popup window with a list control as a child are attached to an edit control. A window with a pseudo-button is wrapped around the edit control to provide combobox-like functionality.

The edit control is modeled in similar style to MFC. However, I do not use Windows messages to provide functionality. Therefore, you can not assume that the following will work.

In the future, I will try to make this functionality available.

The edit control (as does the list control) derives from the respective MFC control as well as CSharedCtrlAttribs. This class is there to provide the ability to change the color of a control.

Please consult the .h files as an API reference.

Known Bugs


Example Usage

Here's an example of creating a dynamic combo box.
BOOL CTypingAidDemoDlg::OnInitDialog()
 // Usual Dialog Stuff here ...

 // Create the combo box
 m_pdynCombo = new CTypingAidCombo(TAES_HASLIST);
 m_pdynCombo->Create(CRect(100, 30, 200, 25), 

 // Set the colors
 CTypingAidEdit* pEdit = m_ppdynCombo[i]->GetEdit();
 pEdit->SetTextColor(RGB(255, 0, 0));
 pEdit->SetBkColor(RGB(0, 255, 255));

 // Add some columns and items
 CListCtrl* pListCtrl = m_ppdynCombo[i]->GetListCtrl();
 pListCtrl->InsertColumn(0, "From", LVCFMT_LEFT, 100);
 pListCtrl->InsertColumn(1, "Import Value", LVCFMT_LEFT, 100);
 LVITEM lvi;
 ::ZeroMemory(&lvi, sizeof(lvi));
 lvi.mask = LVIF_TEXT;
 lvi.iSubItem = 0;

 lvi.pszText = "Hello1";
 lvi.pszText = "Hello 2";

 pListCtrl->SetItemText(0, 1, "Apples");
 pListCtrl->SetItemText(1, 1, "oranges");

 // ...


Download source - 24 Kb
Download demo project - 36 Kb


  • how to make the button disabled when the edit has no content!

    Posted by Legacy on 09/28/2003 07:00am

    Originally posted by: huaboy

    Thanks for the nice controll.I have used it in my application,but I want to make the button control disabled when no content typed in the edit field;only when the user starts to type something in the edit field,make the button visible!
    I can't find the button control in the source,please tell me the method how to change the button controll status!

  • How to show the list control contents when the user start to type the text

    Posted by Legacy on 12/10/2002 08:00am

    Originally posted by: Ivaylo Geoirgiev

    Thanks for the nice controll.
    I want to use it in my application but it would be better if I can show all the items in the list controll when the user start to type something in edit field,like ShowDropDown(true) in the common combo box.
    My idea is that it to work like in MS Visio Studio.

    I've tried to show the list in CTypingAidEdit::OnChar(...)
    with Using ShowListBox(), but without success.

    Ivaylo Georgiev, BG

  • unable to change font of CTypingAidCombo Object

    Posted by Legacy on 05/30/2002 07:00am

    Originally posted by: laxmikant p pa til

    when i created object of CTyingAid Combo , then i have successfully changed colour of control but i am not able to change font , because by default it takes , bold characters
    which is not looking good & takes too much space for small number of characters
    please send me answer as early as possible

  • Undeclared symbol OBM_COMBO

    Posted by Legacy on 03/14/2002 08:00am

    Originally posted by: laxmikant panditrao patil

    Code gives error when used with other program
    it is giving error like undeclared symbol obm_combo
    what should i do for that

  • Can you make autocomplete only working from the begining of the sequence?

    Posted by Legacy on 07/06/2001 07:00am

    Originally posted by: Ivaylo

    Thanks for the nice control.

    I made it to work like custom control, with registerclass..
    It is more confortable to work with. If somebody is interested how I will show next.
    For my use I remove stack atribute and deleting all rows after making selection from user.
    In 'find match' function find some bug in exiting from while.

    But it is not a good idea autocomplete with substrins after user placing 'space bar'.

    Do you can correct it?

    By the way I very much like this style of explaining combobox.

    Ivaylo G.
    Swisscom Ltd.

  • You must have javascript enabled in order to post comments.

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

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date