Create a new ComboExo using VS2013
2025-11-04
Written by: xiaobin
The original example was written using VC6.0; now we will rewrite it using VS2013. After downloading, click “Extract” to extract the source files.
Move files to the “res” directory:
D8016 '/ZI' and '/Gy-' command-line options are incompatible
C/C++ -> General -> Debug Information Format
Program Database(/Zi)
default
Cancel All
MFC standard
none
Drag and drop from the toolbox:
There are two ways to adjust the list height:

COMBOBOX IDC_COMBO1,58,39,48,30,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP
new data: Height of the 4 items
COMBOBOX IDC_COMBO1,58,39,48,48,CBS_DROPDOWN | CBS_SORT | WS_VSCROLL | WS_TABSTOP
IDC_COMBO1 -> Properties
Click the “CBN_SELCHANGE” event property and select ”
void CComboExoDlg::OnCbnSelchangeCombo1()
{
// TODO: Add your control notification handler code here
CString strTemp;
int nCurSel;
nCurSel = ((CComboBox*)GetDlgItem(IDC_COMBO1))->GetCurSel();
((CComboBox*)GetDlgItem(IDC_COMBO1))->GetLBText(nCurSel, strTemp);
GetDlgItem(IDC_EDIT1)->SetWindowText(strTemp);
}
// Add 20 items to the combo box.
CString str;
for (int i = 0; i < 20; i++)
{
str.Format(_T("item string %d"), i);
((CComboBox*)GetDlgItem(IDC_COMBO1))->AddString(str);
}