http://blog.csdn.net/baizengfei/article/details/7997618
//第一种方法
int number1, number2, number3;
char char1[10], char2[10], char3[10];
GetDlgItem(IDC_EDIT1)->GetWindowText(cahr1, 10);
GetDlgITem(IDC_EDIT2)->GetWindowText(char2, 10);
number1 = atoi(char1);
number2 = atoi(char2);
number3 = number1 +number2;
itoa(number3, char3, 10);
GetDlgItem(IDC_EDIT3)->SetWindowText(cahr3);
//第二种方法
char char1[10], char2[10], char3[10];
int number1, number2, number3;
GetDlgItemText(IDC_EDIT1, char1, 10);
GetDlgITemText(IDC_EDIT2, char2, 10);
number1 = atoi(char1);
number2 = atoi(char2);
number3 = number1 + number2;
itoa(number3, char3, 10);
SetDlgItemText(IDC_EDIT3, char3);
//第三种方法
int number1, number2, number3;
number1 = GetDlgItemInt(IDC_EDIT1);
number2 = GetDlgITemInt(IDC_EDIT2);
number3 = number1 + number2;
SetDlgItemInt(IDC_EDIT3, number3);
//第四种方法
*在ClassWizard中的Member中找到IDC_EDIT1和IDC_EDIT2的Control IDs双击IDC_EDIT1和IDC_EDIT2打开Add MemberVariable
添加MemberVariableName的新名字(m_number1)
CateGory:Value;
Variable Type: Int;
OK!
void CTest_3Dlg::OnButton1()
{
UpdateData();
m_number3 = m_number1 + m_number2;
UpdateData(FALSE);
DoDateExChange;MSDN说明这个函数程序代码从来是不调用的,而是由我们通过CWnd类的另一个函数来调用的(UpdateData());来实现的。
}
//第五种方法
int number1, number2, number3;
char char1[10], char2[10], char3[10];
m_ctrlEDIT1.GetWindowText(char1, 10);
m_ctrlEDIT2.GetWindowText(char2, 10);
number1 = atoi(char1);
number2 = atoi(char2);
number3 = number1 + number2;
itoa(number3, char3, 10);
m_ctrlEDIT3.SetWindowText(char3);
//第六种方法
int num1, num 2, num3;
char ch1[10], ch2[10], ch3[10];
::SendMessage(GetDlgItem(IDC_EDIT1)->m_Hwnd), WM_GETTEXT, 10, (LPARAW)ch1);
::SendMessage(m_ctrlEDIT2.m_Hwnd), WM_GETTEXT, 10, (LPARAW)ch2);
num1 = atoi(ch1);
num2 = atoi(ch2);
num3 = num1 + num2;
m_ctrlEDIT3.SendMessage(WM_SETTETXT, 10, (LPARAW), ch3);
//第七种方法;
int num1, num2, num3;
char ch1[10], ch2[10], ch3[10];
SendDlgItemMessage(IDC_EDIT1, WM_GETTEXT, 10, (LPARAM)ch1);
SendDlgItemMessage(IDC_EDIT2, WM_GETTEXT, 10, (LPARAM)ch2);
num1 = atoi(ch1);
num2 = atoi(ch2);
num3 = num1 + num2;
SendDlgItemMessage(IDC_EDIT3, WM_SETTEXT, 10, (LPARAM)ch3);