Limits the number of characters the user can enter in the edit control portion.
C
int WINAPI SftBox_LimitText(HWND hwndCtl, int maxChars);
C++
int CSftBox::LimitText(int maxChars);
hwndCtl
The window handle of the combo box control.
maxChars
The maximum number of characters the user can enter. If 0 is specified, the number of characters is not limited by the combo box.
The return value is 0 if the function was successful. -1 is returned if maxChars is negative or if the combo box is a dropdown list combo box, which does not have an edit control portion.
The LimitText function limits the number of characters the user can enter in the edit control portion of a simple or dropdown combo box.
By default, the number of characters is not limited (0).
The limit only applies to text entered by the user. It does not affect text that is already in the edit control portion when LimitText is called, and it does not limit the text which is copied to the edit control portion when an item is selected.
SftBox_SetShowResizer(hwndBox, TRUE); // The user can resize the dropdown
SftBox_SetDarkMode(hwndBox, SFTBOX_DARKMODE_AUTO);
// The edit portion shows and searches this column.
SftBox_SetEditSearchColumn(hwndBox, editColumn);
// Typing completes the text with the first matching item.
SftBox_SetEditSearchMode(hwndBox, SFTBOX_SEARCH_AUTOCOMPLETE);
if (editColumn == COL_ABBR)
SftBox_LimitText(hwndBox, 2);
for (i = 0 ; i < STATE_COUNT ; ++i) {
LONG index = SftBox_AddString(hwndBox, m_aStates[i].lpszName);
SftBox_SetText(hwndBox, index, COL_ABBR, m_aStates[i].lpszAbbr);
SftBox_SetText(hwndBox, index, COL_CAPITAL, m_aStates[i].lpszCapital);
}
box.SetShowResizer(TRUE); // The user can resize the dropdown
box.SetDarkMode(SFTBOX_DARKMODE_AUTO);
// The edit portion shows and searches this column.
box.SetEditSearchColumn(editColumn);
// Typing completes the text with the first matching item.
box.SetEditSearchMode(SFTBOX_SEARCH_AUTOCOMPLETE);
if (editColumn == COL_ABBR)
box.LimitText(2);
for (int i = 0 ; i < STATE_COUNT ; ++i) {
LONG index = box.AddString(m_aStates[i].lpszName);
box.SetText(index, COL_ABBR, m_aStates[i].lpszAbbr);
box.SetText(index, COL_CAPITAL, m_aStates[i].lpszCapital);
}
See Also C/C++ API | Categories | Notifications