updatedata(MFC)
时间:2010-03-10 来源:cr858923
1.(类向导)
如果m_Edit1是value (category为value时,即m_Edit1为一变量)
//取值
UpdateData(TRUE);
CString buf = m_Edit1;
....
//赋值
m_Edit1 = "ok!";
UpdateData(FALSE); 例: UpdateData(TRUE);
if(m_num1<0||m_num1>100||m_num2<0||m_num2>100)
{
MessageBox("请重新输入");
}
else
{
m_numResult = m_num1 + m_num2;
}
UpdateData(FALSE); 2.(类向导) 如果m_Edit1是control (category为control时,即mcEdit1为一对象) CString str = "abc"; m_Edit1.SetWindowText(str); CString string; m_Edit1.GetWindowText(string); //取值
3. (通过控件ID) CString str = "abc"; SetDlgItemText(IDC_EDIT1,str); CString string; GetDlgItemText(IDC_EDIT1,string); //取值 或 (通过获得指向控件的临时指针,GetDlgItem()方法) CString str = "abc";
GetDlgItem(IDC_EDIT1)->SetWindowText(str); CString string;
GetDlgItem(IDC_EDIT1)->GetWindowText(string); //取值
//取值
UpdateData(TRUE);
CString buf = m_Edit1;
....
//赋值
m_Edit1 = "ok!";
UpdateData(FALSE); 例: UpdateData(TRUE);
if(m_num1<0||m_num1>100||m_num2<0||m_num2>100)
{
MessageBox("请重新输入");
}
else
{
m_numResult = m_num1 + m_num2;
}
UpdateData(FALSE); 2.(类向导) 如果m_Edit1是control (category为control时,即mcEdit1为一对象) CString str = "abc"; m_Edit1.SetWindowText(str); CString string; m_Edit1.GetWindowText(string); //取值
3. (通过控件ID) CString str = "abc"; SetDlgItemText(IDC_EDIT1,str); CString string; GetDlgItemText(IDC_EDIT1,string); //取值 或 (通过获得指向控件的临时指针,GetDlgItem()方法) CString str = "abc";
GetDlgItem(IDC_EDIT1)->SetWindowText(str); CString string;
GetDlgItem(IDC_EDIT1)->GetWindowText(string); //取值
相关阅读 更多 +