利用windows的方法:
方法6:
void CMFCDlg::OnBnClickedButton6()
{
// TODO: 在此添加控件通知处理程序代码
int num1,num2,num3;
TCHAR ch1[12],ch2[12],ch3[12];
//全局作用的windowsAPI函数(窗口句柄,获取消息,消息大小,传递给ch1)
::SendMessage(GetDlgItem(IDC_EDIT1)->m_hWnd,WM_GETTEXT,12,(LPARAM)ch1);
::SendMessage(GetDlgItem(IDC_EDIT2)->m_hWnd,WM_GETTEXT,12,(LPARAM)ch2);
num1=_ttoi(ch1);
num2=_ttoi(ch2);
num3=num1+num2;
_itot(num3,ch3,10);
::SendMessage(GetDlgItem(IDC_EDIT3)->m_hWnd,WM_SETTEXT,0,(LPARAM)ch3);
}
方法7:
void CMFCDlg::OnBnClickedButton7()
{
// TODO: 在此添加控件通知处理程序代码
int num1,num2,num3;
TCHAR ch1[12],ch2[12],ch3[12];
SendDlgItemMessage(IDC_EDIT1,WM_GETTEXT,12,(LPARAM)ch1);
SendDlgItemMessage(IDC_EDIT2,WM_GETTEXT,12,(LPARAM)ch2);
num1=_ttoi(ch1);
num2=_ttoi(ch2);
num3=num1+num2;
_itot(num3,ch3,10);
SendDlgItemMessage(IDC_EDIT3,WM_SETTEXT,0,(LPARAM)ch3);
}