The SECComboBoxEx class extends MFC's CComboBoxEx class by providing a type ahead or autocomplete feature. The Address combobox in MS Internet Explorer provides the same functionality. As the user types, the control searches through its list of entries for a match. If the control finds a match to the partial entry, it substitutes the text in the edit control with first matching entry and highlights the characters to the right the caret.
The autocomplete feature also skips ahead when the user types in an entry that includes a regularly repeating delimiter strings sequence, such as the "." in an IP address or the slash character (/) in an URL.
When the user presses the delimiter key once, the entry appears as follows:
When the user presses the delimiter key twice, the entry appears as follows:
When the user presses the delimiter key three times, the entry appears as follows:
The user can always click the button to the right to drop down the list of items as well.
The SECComboBoxEx class inherits directly from CComboBoxEx.
The following procedures describe how to use an enhanced combo box in your application.
To add SECComboBoxEx to a window:
Use the CComboBox::Create() method. For example:
m_combo.Create(WS_CHILD | WS_VISIBLE | CBS_DROPDOWN, CRect(10,10,350,100), this, ID_COMBOBOX); |
To add string items to the combo box:
Use the CComboBox::InsertItem() method. For example:
COMBOBOXEXITEM comboItem; memset(&comboItem, 0, sizeof(comboItem)); comboItem.mask = CBEIF_TEXT; comboItem.iItem = 0; comboItem.pszText = _T("<stingray-installdir>\\Include"); m_combo.InsertItem(&comboItem); |
where <stingray-installdir> refers to the top-level directory in your Stingray Studio installation.
To set the case sensitivity for the autocomplete feature:
Call the CComboBox::SetCaseSensitive() method.
m_combo.SetCaseSensitive(FALSE); |
The preceding call ensures that the autocomplete feature does not consider the case of the characters when it searches for a matching entry in the list.
To allow users to skip repeating delimiters:
Use the CComboBox::SetDelimiterKey() and SetDelimiterString() methods. For example, if the combobox contains long directory entries delimited by two backslashes, you can let the user skip the next delimiter by pressing the <TAB> key with the following calls.
m_combo.SetDelimiterKey(VK_TAB); m_combo.SetDelimiterString(_T("\\")); |
Copyright © Rogue Wave Software, Inc. All Rights Reserved.
The Rogue Wave name and logo, and Stingray, are registered trademarks of Rogue Wave Software. All other trademarks are the property of their respective owners.
Provide feedback to Rogue Wave about its documentation.