对话框访问的7种方式【孙鑫老师教程】

对话框访问的7种方式【孙鑫老师教程】_第1张图片

以上7中方式的代码实现:

/* CString t1,t2;
    int a1,a2,a3;
    (GetDlgItem(IDC_EDIT1)->GetWindowTextW(t1));
    (GetDlgItem(IDC_EDIT2)->GetWindowTextW(t2));
    a1=_ttoi(t1);
    a2=_ttoi(t2);
    a3=a1+a2;
     TCHAR t3[10]; 
    _itow_s(a3, t3,10,10);
    GetDlgItem(IDC_EDIT3)->SetWindowTextW( t3);*/

    /*CString t1,t2;
    int a1,a2,a3;
    GetDlgItemText(IDC_EDIT1,t1); //此处返回的是文本的字符数,不能让a1=这个值。
    GetDlgItemText(IDC_EDIT2,t2);
    a1=_ttoi(t1);
    a2=_ttoi(t2);
    a3=a1+a2;
    TCHAR t3[10];
    _itow_s(a3,t3,10,10);
    SetDlgItemText(IDC_EDIT3,t3);*/

    /*CString t1,t2;
    int a1,a2,a3;
    a1=GetDlgItemInt(IDC_EDIT1);
    a2=GetDlgItemInt(IDC_EDIT2);
    a3=a1+a2;
    SetDlgItemInt(IDC_EDIT3,a3);*/
    
    /*UpdateData();
    m_a3=m_a1+m_a2;
    UpdateData(FALSE);*/

    /*CString t1,t2;
    int a1,a2,a3;
    m_edit1.GetWindowTextW(t1);
    m_edit2.GetWindowTextW(t2);
    a1=_ttoi(t1);
    a2=_ttoi(t2);
    a3=a1+a2;
    TCHAR t3[10];
    _itow_s(a3,t3,10,10);
    m_edit3.SetWindowTextW(t3);*/
    
    /*TCHAR t1[10],t2[10],t3[10];
    int a1,a2,a3;
    m_edit1.SendMessage(WM_GETTEXT,10,(LPARAM)t1);
    m_edit2.SendMessage(WM_GETTEXT,10,(LPARAM)t2);
    a1=_ttoi(t1);
    a2=_ttoi(t2);
    a3=a1+a2;
    _itow_s(a3,t3,10,10);
    m_edit3.SendMessage(WM_SETTEXT,10,(LPARAM)t3);*/

    /*TCHAR t1[10],t2[10],t3[10];
    int a1,a2,a3;
    SendDlgItemMessageW(IDC_EDIT1,WM_GETTEXT,10,(LPARAM)t1);
    SendDlgItemMessageW(IDC_EDIT2,WM_GETTEXT,10,(LPARAM)t2);
    a1=_ttoi(t1);
    a2=_ttoi(t2);
    a3=a1+a2;
    _itow_s(a3,t3,10,10);
    SendDlgItemMessageW(IDC_EDIT3,WM_SETTEXT,10,(LPARAM)t3);*/

 

转载于:https://www.cnblogs.com/hometown/p/3478197.html

你可能感兴趣的:(对话框访问的7种方式【孙鑫老师教程】)