首页 > 代码库 > MFCSimpleCtrl
MFCSimpleCtrl
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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。