GetWindowText怎么用?

来源:百度知道 编辑:UC知道 时间:2024/06/08 14:00:05
下面是小弟在VC++6.0中编写的一段程序代码:
void CScoreAddDlg::OnOK()
{
// TODO: Add extra validation here
CString student,course,score,student_no,course_no;
m_cStudent.GetWindowText(student);//这里提示有错误
m_cCourse.GetWindowText(course);
m_cScore.GetWindowText(score);
if(score=="") MessageBox("请输入成绩!");
else
{
CString strSQL;
strSQL.Format("select * from student where active_status='Y' and student_name='%s'",student);
CRecordset m_recordSet=&m_database;
m_recordSet.Open(CRecordset::forwardOnly,strSQL);
m_recordSet.GetFieldValue("student_no",student_no);
m_recordSet.Close();
if(this->id=="0")
{
strSQL.Format("insert into score(student_no,course_no,score,active_status)values('%s','%s',%s,'Y')",student_no,course_no,score);
m_database.ExecuteSQL(strSQL);
}
else

你这里m_cStudent定义成控件CString类型的变量,这样写肯定是不行的了,如果要GetWindowText,可以:GetDlgItem(控件ID号)->GetWindowText(student);
或者定义一个控件的controy-CEdit 类型变量xxx,可以写成xxx.GetWindowText(...);