/****************方法一**********************************
int num1,num2,num3;
char ch1[10],ch2[10],ch3[10];
GetDlgItem(IDC_EDIT3)->GetWindowText(ch1,10);
GetDlgItem(IDC_EDIT4)->GetWindowText(ch2,10);
num1 = atoi(ch1);
num2 = atoi(ch2);
num3 = num1 + num2;
itoa(num3,ch3,10);
GetDlgItem(IDC_EDIT5)->SetWindowText(ch3);*/
/***************方法二************************************
int num1,num2,num3;
char ch1[10],ch2[10],ch3[10];
GetDlgItemText(IDC_EDIT3,ch1,10);
GetDlgItemText(IDC_EDIT4,ch2,10);
num1 = atoi(ch1);
num2 = atoi(ch2);
num3 = num1 + num2;
itoa(num3,ch3,10);
SetDlgItemText(IDC_EDIT5,ch3);*/
/**************方法三*************************************
//可以进行符号运算,如-1+-1=-2
int num1,num2,num3;
num1 = GetDlgItemInt(IDC_EDIT3);
num2 = GetDlgItemInt(IDC_EDIT4);
num3 = num1 + num2;
SetDlgItemInt(IDC_EDIT5,num3);*/
/**************方法四*************************************
//利用成员变量,注意UpdateData
UpdateData();
m_num03 = m_num01 + m_num02;
UpdateData(0);*/
/*************方法五*************************************
//利用控件成员变量
int num1,num2,num3;
char ch1[10],ch2[10],ch3[10];
m_edit1.GetWindowText(ch1,10);
m_edit2.GetWindowText(ch2,10);
num1 = atoi(ch1);
num2 = atoi(ch2);
num3 = num1 + num2;
itoa(num3,ch3,10);
m_edit3.SetWindowText(ch3);*/
/************方法六**************************************
//利用系统消息机制SendMessage
int num1,num2,num3;
char ch1[10],ch2[10],ch3[10];
::SendMessage(GetDlgItem(IDC_EDIT3)->m_hWnd,WM_GETTEXT,10,(LPARAM)ch1);
::SendMessage(m_edit2.m_hWnd,WM_GETTEXT,10,(LPARAM)ch2);
num1 = atoi(ch1);
num2 = atoi(ch2);
num3 = num1 + num2;
itoa(num3,ch3,10);
m_edit3.SendMessage(WM_SETTEXT,0,(LPARAM)ch3);*/
/************方法七**************************************
//同样采用消息SendDlgItemMessage*/
int num1,num2,num3;
char ch1[10],ch2[10],ch3[10];
SendDlgItemMessage(IDC_EDIT3,WM_GETTEXT,10,(LPARAM)ch1);
SendDlgItemMessage(IDC_EDIT4,WM_GETTEXT,10,(LPARAM)ch2);
num1 = atoi(ch1);
num2 = atoi(ch2);
num3 = num1 + num2;
itoa(num3,ch3,10);
SendDlgItemMessage(IDC_EDIT5,WM_SETTEXT,0,(LPARAM)ch3);