Defines the index of the selected item.
C
LONG WINAPI SftBox_GetCurSel(HWND hwndCtl); int WINAPI SftBox_SetCurSel(HWND hwndCtl, LONG indexTC);
C++
LONG CSftBox::GetCurSel() const; int CSftBox::SetCurSel(LONG indexTC);
hwndCtl
The window handle of the combo box control.
indexTC
The zero-based index of the item to be selected. This parameter may be -1 to deselect the currently selected item.
GetCurSel returns the zero-based index of the currently selected item. If no item is selected, the value -1 is returned.
SetCurSel returns the value 0 if the function was successful, otherwise -1 is returned.
The GetCurSel and SetCurSel functions define the index of the selected item.
A combo box control has one selected item or no selected item. The selected item is highlighted in the dropdown portion. In a dropdown list combo box, the selected item is shown in the static portion. In a simple or dropdown combo box, SetCurSel copies the selected item's cell text to the edit control portion. The text of the first displayed column is used, unless another column has been defined using SetEditSearchColumn. If -1 is specified to deselect the currently selected item, the edit control portion is cleared.
If the item to be selected is not visible because a parent item is collapsed, SetCurSel expands the parent item(s) to make the item visible.
If the selected item changes, SetCurSel sends the SFTBOXN_SELCHANGE notification to the parent window.
SetColorSample(hwndBox, index, m_aColors[i].color);
}
SftBox_MakeColumnOptimal(hwndBox, -1, 0); // Make all columns optimal
SftBox_RecalcHorizontalExtent(hwndBox, 0);
// Select the item with the requested color, searching after the custom color
index = SftBox_FindItem(hwndBox, CUSTOM_INDEX + 1, selected);
SftBox_SetCurSel(hwndBox, index >= 0 ? index : CUSTOM_INDEX);
}
static COLORREF GetSelectedColor(HWND hwndBox)
{
LONG index = SftBox_GetCurSel(hwndBox);
if (index < 0)
return RGB(0, 0, 0);
SetColorSample(box, index, m_aColors[i].color);
}
box.MakeColumnOptimal(-1, 0); // Make all columns optimal
box.RecalcHorizontalExtent(0);
// Select the item with the requested color, searching after the custom color
index = box.FindItem(CUSTOM_INDEX + 1, selected);
box.SetCurSel(index >= 0 ? index : CUSTOM_INDEX);
}
COLORREF CMainDlg::GetSelectedColor(const CSftBox& box) const
{
LONG index = box.GetCurSel();
if (index < 0)
return RGB(0, 0, 0);See Also C/C++ API | Categories | Notifications