GetWindowText怎么用?
下面是小弟在VC++6.0中编写的一段程序代码:voidCScoreAddDlg::OnOK(){//TODO:AddextravalidationhereCString...
下面是小弟在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
{
strSQL.Format("update score set student_no='%s',course_no='%s',score=%s where score_id=%s",student_no,course_no,score,id);
m_database.ExecuteSQL(strSQL);
}
CDialog::OnOK();
}
在上面注释行提示有错误 error C2039: 'GetWindowTextA' : is not a member of 'CString',那么这个函数GetWindowText到底应该怎么用呢?谢谢!
另外在上面的if语句中提示error C2039: 'id' : is not a member of 'CScoreAddDlg',那么这里应该怎样写呢?id是用来判断添加记录或修改记录的 展开
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
{
strSQL.Format("update score set student_no='%s',course_no='%s',score=%s where score_id=%s",student_no,course_no,score,id);
m_database.ExecuteSQL(strSQL);
}
CDialog::OnOK();
}
在上面注释行提示有错误 error C2039: 'GetWindowTextA' : is not a member of 'CString',那么这个函数GetWindowText到底应该怎么用呢?谢谢!
另外在上面的if语句中提示error C2039: 'id' : is not a member of 'CScoreAddDlg',那么这里应该怎样写呢?id是用来判断添加记录或修改记录的 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询