码迷,mamicode.com
首页 > 编程语言 > 详细

MFCSimpleCtrl

时间:2016-10-28 03:15:29      阅读:175      评论:0      收藏:0      [点我收藏+]

标签:git   ext   span   name   simple   load   分享   ges   one   

技术分享

BOOL CDemoMFCCtrlDlg::OnInitDialog()
{
//...

    SetDlgItemText(IDC_EDIT1, _T("Name"));
    SetDlgItemText(IDC_EDIT2, _T("PassWord"));
    ((CButton*)GetDlgItem(IDC_RADIO1))->SetCheck(1);
    ((CButton*)GetDlgItem(IDC_CHECK1))->SetCheck(1);

    return TRUE;  
}

void CDemoMFCCtrlDlg::OnBnClickedButton1()
{
    //Load
    CString strShow;
    CString strDlgItemText;
    //get name
    GetDlgItemText(IDC_EDIT1, strDlgItemText);
    strShow += strDlgItemText;
    strShow += "|";
    //get password
    GetDlgItemText(IDC_EDIT2, strDlgItemText);
    strShow += strDlgItemText;
    strShow += "|";
    //get gender
    int iGender = GetCheckedRadioButton(IDC_RADIO1, IDC_RADIO3);
    switch (iGender)
    {
    case IDC_RADIO1:
        GetDlgItemText(IDC_RADIO1, strDlgItemText);
        break;
    case IDC_RADIO2:
        GetDlgItemText(IDC_RADIO2, strDlgItemText);
        break;
    case IDC_RADIO3:
        GetDlgItemText(IDC_RADIO3, strDlgItemText);
        break;
    }
    strShow += strDlgItemText;
    strShow += "|";
    //get occupation
    if (((CButton*)GetDlgItem(IDC_CHECK1))->GetCheck())
    {
        GetDlgItemText(IDC_CHECK1, strDlgItemText);
        strShow += strDlgItemText;
        strShow += "|";
    }
    if (((CButton*)GetDlgItem(IDC_CHECK2))->GetCheck())
    {
        GetDlgItemText(IDC_CHECK2, strDlgItemText);
        strShow += strDlgItemText;
        strShow += "|";
    }
    if (((CButton*)GetDlgItem(IDC_CHECK3))->GetCheck())
    {
        GetDlgItemText(IDC_CHECK3, strDlgItemText);
        strShow += strDlgItemText;
        strShow += "|";
    }
    MessageBox(strShow);
}

void CDemoMFCCtrlDlg::OnEnChangeEdit1()
{
    // TODO:  如果该控件是 RICHEDIT 控件,它将不
    // 发送此通知,除非重写 CDialog::OnInitDialog()
    // 函数并调用 CRichEditCtrl().SetEventMask(),
    // 同时将 ENM_CHANGE 标志“或”运算到掩码中。

    //控件IDC_EDIT1内容发生变化时
    //CString str;
    //GetDlgItemText(IDC_EDIT1, str);
    //MessageBox(str);
}



void CDemoMFCCtrlDlg::OnBnClickedRadio1()
{
    //控件IDC_RADIO1左击选中时
    //CString str;
    //GetDlgItemText(IDC_RADIO1, str);
    //MessageBox(str);
}

void CDemoMFCCtrlDlg::OnBnClickedCheck1()
{
    //控件IDC_CHECK1左击时
    //if (((CButton*)GetDlgItem(IDC_CHECK1))->GetCheck())
    //{
    //    CString str;
    //    GetDlgItemText(IDC_CHECK1, str);
    //    MessageBox(str);
    //}
}

 

MFCSimpleCtrl

标签:git   ext   span   name   simple   load   分享   ges   one   

原文地址:http://www.cnblogs.com/nonebutnow/p/6006092.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!