LouZhang

导航

对话框控件访问七种方式

nGetDlgItem()->Get(Set)WindowText()
nGetDlgItemText()/SetDlgItemText()
nGetDlgItemInt()/SetDlgItemInt()
n将控件和整型变量相关联
n将控件和控件变量相关联
nSendMessage()
nSendDlgItemMessage()
 
void CTestDlg::OnBnClickedOk2()
{
    // TODO: 在此添加控件通知处理程序代码
/*    int num1, num2, num3;
    char ch1[10], ch2[10], ch3[10];
    GetDlgItem(IDC_EDIT1)->GetWindowTextA(ch1, 10);
    GetDlgItem(IDC_EDIT2)->GetWindowTextA(ch2, 10);
    num1 = atoi(ch1);
    num2 = atoi(ch2);
    num3 = num1 + num2;
    _itoa_s(num3,ch3,10);
    GetDlgItem(IDC_EDIT3)->SetWindowTextA(ch3);*/

/*
    int num1, num2, num3;
    char ch1[10], ch2[10], ch3[10];
    GetDlgItemText(IDC_EDIT1, ch1, 10);
    GetDlgItemText(IDC_EDIT2, ch2, 10);
    num1 = atoi(ch1);
    num2 = atoi(ch2);
    num3 = num1 + num2;
    _itoa_s(num3,ch3,10);
    SetDlgItemText(IDC_EDIT3, ch3);*/


/*    int num1, num2, num3;
    num1 = GetDlgItemInt(IDC_EDIT1);
    num2 = GetDlgItemInt(IDC_EDIT2);
    num3 = num1 + num2;
    SetDlgItemInt(IDC_EDIT3, num3);*/

/*    UpdateData();
    m_num3 = m_num1 + m_num2;
    UpdateData(FALSE);*/

/*    int num1, num2, num3;
    char ch1[10], ch2[10], ch3[10];
    m_edit1.GetWindowTextA(ch1, 10);
    m_edit2.GetWindowTextA(ch2, 10);
    num1 = atoi(ch1);
    num2 = atoi(ch2);
    num3 = num1 + num2;
    _itoa_s(num3,ch3,10);
    m_edit3.SetWindowTextA(ch3);*/

/*    int num1, num2, num3;
    char ch1[10], ch2[10], ch3[10];
    //::SendMessage(GetDlgItem(IDC_EDIT1)->m_hWnd, WM_GETTEXT, 10, (LPARAM)ch1);
    //::SendMessage(m_edit1.m_hWnd, WM_GETTEXT, 10, (LPARAM)ch1);
    //GetDlgItem(IDC_EDIT1)->SendMessage(WM_GETTEXT, 10, (LPARAM)ch1);
    m_edit1.SendMessage(WM_GETTEXT, 10, (LPARAM)ch1);
    m_edit2.SendMessage(WM_GETTEXT, 10, (LPARAM)ch2);
    num1 = atoi(ch1);
    num2 = atoi(ch2);
    num3 = num1 + num2;
    _itoa_s(num3,ch3,10);
    m_edit3.SendMessage(WM_SETTEXT, 0, (LPARAM)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;
    _itoa_s(num3,ch3,10);
    SendDlgItemMessage(IDC_EDIT3, WM_SETTEXT, 0, (LPARAM)ch3);
    */


}

 

posted on 2012-09-25 13:51  louzhang_swk  阅读(277)  评论(0编辑  收藏  举报