右键点击combo控件,选择event,然后选择ON_CBN_SELCHANGE(看到selchange就可以).
然后点add and edit.
void CTest02Dlg::OnSelChange()
{
int x;
int index=(CComboBox*GetDlgItem(IDC_COMBO))->GetCurSel();
if(index==0)x=1;
else x==2;
}
error C2653: 'CTest02Dlg' : is not a class or namespace name
error C2146: syntax error : missing ')' before identifier 'GetDlgItem'
error C2065: 'IDC_COMBO' : undeclared identifier
error C2059: syntax error : ')'
error C2227: left of '->GetCurSel' must point to class/struct/union
warning C4553: '==' : operator has no effect; did you intend '='?