Building the Right Environment to Support AI, Machine Learning and Deep Learning
To use this icon combo box, follow these simple steps.
- Include IconComboBox.cpp and IconComboBox.h in your project.
- In the resource editor create a regular combobox with at least the following styles: DropList, OwnerDraw Variable, Has Strings
- Create a control member variable for the combobox in VC's classwizard.
- Replace CComboBox with CIconComboBox in your .h file.
Figure1 - Sample picture of the IconComboBox in action
virtual int AddIcon(LPCTSTR lpszIconFileName);
virtual int InsertIcon(int nIndex, LPCTSTR lpszIconFileName);
virtual int SelectIcon(LPCTSTR lpszIconFileName);
virtual int SelectIcon(int nIndex);
virtual int DeleteIcon(LPCTSTR lpszIconFileName);
virtual int DeleteIcon(int nIndex);
The following method can be overrided to paint the icon in a different way. Normally the icon is drawn centered within the combobox.
virtual void OnOutputIcon(LPDRAWITEMSTRUCT lpDIS, BOOL bSelected);
It is important that the style Has Strings (CBS_HASSTRINGS) is specified, because the filename of the icon is actually stored in the combobox for later use if you select or delete an icon. The width of the combobox is decided by you when you create the control. The height can be set manually with the following statement:
m_cbMyIconComboBox.SetItemHeight(-1, m_cbMyIconComboBox.m_sizeIcon.cy + 6);
where m_sizeIcon.cy are a standard icon height (SM_CYICON).
Download source files - 2 KB