C++高手进!~

来源:百度知道 编辑:UC知道 时间:2024/07/02 15:08:14
在MFC ApplicationWizard(exe)中新建一个基于对话框的程序,在Dialog中添加Combo1控件,添加Dialog的"确定"响应函数如下:

void CTest2Dlg::OnOK()
{
cstring strmess;
getdlgitem(idc_combo1)->getwindowtext(strmess);
strmess="你选择了:"+strmess;
afxmessagebox(strmess);

CDialog::OnOK();
}
按Ctrl+F5后,提示出错.以下是提示内容:
--------------------Configuration: Test2 - Win32 Debug--------------------
Compiling...
Test2Dlg.cpp
D:\Test2Dlg.cpp(177) : error C2065: 'cstring' : undeclared identifier
D:\Test2Dlg.cpp(177) : error C2146: syntax error : missing ';' before identifier 'strmess'
D:\Test2Dlg.cpp(177) : error C2065: 'strmess' : undeclared identifier
D:\Test2Dlg.cpp(178) : error C2065: 'getdlgitem' : undeclared identifier
D:\Test2Dlg.cpp(178) : error C2065: 'idc_combo1' : undeclared identifier
D:\Test2Dlg.cpp(178) : error C2227: left of '->ge

请注意你的大小写,C++区分大小写的
cstring->CString
idc_combo1->IDC_COMBO1
getdlgitem->GetDlgItem
getwindowtext->GetWindowText
afxmessagebox->AfxMessageBox

好你是CString才对.而不是你写的cstring;