第一种:
int nNum = 0;
TCHAR ch[12] ={};
TCHAR ch1[12] = {};
GetDlgItem(IDC_EDIT1)->GetWindowText(ch,12); //获取
nNum = _ttoi(ch) //通用版的字符转换成数字。
_itot(nNum,ch1,10) //数字转换成字符串
GetDlgItem(IDC_EDIT1)->SetWindowText(ch,12); //设置
第二种:
int nNum = 0;
TCHAR ch[12] ={};
TCHAR ch1[12] = {};GetDlgItemText(IDC_EDIT1,ch,12);
nNum = _ttoi(ch) //通用版的字符转换成数字。
_itot(nNum,ch1,10) //数字转换成字符串SetDlgItemText(IDC_EDIT2,ch1,12);
第三种:
int nNum = 0;
nNum = GetDlgItemInt(IDC_EDIT1);
SetDlgItemInt(IDC_EDIT2,nNum);
//关联
第四种:
把控件和整型变量相关联
int nNum = 0;
TCHAR ch[12] ={};
TCHAR ch1[12] = {};
GetDlgItem(IDC_EDIT1)->GetWindowText(ch,12); //获取
nNum = _ttoi(ch) //通用版的字符转换成数字。
_itot(nNum,ch1,10) //数字转换成字符串
GetDlgItem(IDC_EDIT1)->SetWindowText(ch,12); //设置
第二种:
int nNum = 0;
TCHAR ch[12] ={};
TCHAR ch1[12] = {};GetDlgItemText(IDC_EDIT1,ch,12);
nNum = _ttoi(ch) //通用版的字符转换成数字。
_itot(nNum,ch1,10) //数字转换成字符串SetDlgItemText(IDC_EDIT2,ch1,12);
第三种:
int nNum = 0;
nNum = GetDlgItemInt(IDC_EDIT1);
SetDlgItemInt(IDC_EDIT2,nNum);
//关联
第四种:
把控件和整型变量相关联
用UpdateData 会自动去检查是不是数。
第五种:
把控件和控件变量相关联
第六种:
发送消息
第七种:
发送消息
下面是cstring列子
BOOL CMyDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
CString scNumb = L"jhdghjgghj";
m_Edit5.SetWindowText(scNumb);
//第4种关联方案
nNum1 = 1;
nNum2 = 2;
nNum3 = 3;
UpdateData(FALSE);
// TODO: 在此添加额外的初始化
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
{
CDialogEx::OnInitDialog();
CString scNumb = L"jhdghjgghj";
m_Edit5.SetWindowText(scNumb);
//第4种关联方案
nNum1 = 1;
nNum2 = 2;
nNum3 = 3;
UpdateData(FALSE);
// TODO: 在此添加额外的初始化
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}