none
MFC一个对话框的按钮响应函数中操作另外两个对话框控件出错: RRS feed

  • 问题

  • 一个if....else 语句并列控制两个对话框,IDD_DIALOG1能正常控制,IDD_DIALOG2不能正常运行:

    void C视觉传感器控制台10Dlg::OnBnClickedSwitchbtn() { CString strCaption; GetDlgItem(ModelSwitchBtn)->GetWindowText(strCaption); if(strCaption == "有无检测"||strCaption == "Yes/No Detection") //有无检测界面(IDD_DIALOG2)设置 { YesOrNoRunInterface *YesOrNo_dlg=new YesOrNoRunInterface(); YesOrNo_dlg->Create(IDD_DIALOG2,NULL); YesOrNo_dlg->ShowWindow(SW_SHOWNORMAL); if(language == chinese)//在这里边执行时出错!!!!!!!!!!!!! { YesOrNo_dlg->GetDlgItem(PercentOfPass)->SetWindowTextW(_T("合格率")); YesOrNo_dlg->GetDlgItem(Pass)->SetWindowText(_T("检测数")); YesOrNo_dlg->GetDlgItem(YesOrNoDetection)->SetWindowText(_T("有/无")); YesOrNo_dlg->GetDlgItem(Score)->SetWindowText(_T("评分")); YesOrNo_dlg->GetDlgItem(RespondTime)->SetWindowText(_T("响应时间")); YesOrNo_dlg->GetDlgItem(SwitchBtnSet)->SetWindowText(_T("设置")); } else if(language == english)//在这里边执行时出错!!!!!!!!!!!!! { YesOrNo_dlg->GetDlgItem(PercentOfPass)->SetWindowText(_T("Percent Of Pass")); YesOrNo_dlg->GetDlgItem(Pass)->SetWindowText(_T("Test Amount")); YesOrNo_dlg->GetDlgItem(YesOrNoDetection)->SetWindowText(_T("Ye/No")); YesOrNo_dlg->GetDlgItem(Score)->SetWindowText(_T("Score")); YesOrNo_dlg->GetDlgItem(RespondTime)->SetWindowText(_T("Respond Time")); YesOrNo_dlg->GetDlgItem(SwitchBtnSet)->SetWindowText(_T("Set")); } else { MessageBox(L"IDD_DIALOG2 LanguageSet error",L"error",MB_OKCANCEL); //错误提示 } } else if(strCaption == "RGB参数"||strCaption == "RGB Arguments") //RGB参数检测界面(IDD_DIALOG1)设置 { RGBRunInterface *rgb_dlg = new RGBRunInterface(); rgb_dlg->Create(IDD_DIALOG1,NULL); rgb_dlg->ShowWindow(SW_SHOWNORMAL); // 激活并显示指定窗口,如果该窗口被最大化或最小化,将还原其原本的大小和位置。 if(language == chinese)//在这里边执行时正确!!!!!!!!!!!!! { rgb_dlg->GetDlgItem(PercentOfPass)->SetWindowText(_T("合格率")); rgb_dlg->GetDlgItem(Pass)->SetWindowText(_T("检测数")); rgb_dlg->GetDlgItem(RGBValue)->SetWindowText(_T("RGB值")); rgb_dlg->GetDlgItem(Score)->SetWindowText(_T("评分")); rgb_dlg->GetDlgItem(RespondTime)->SetWindowText(_T("响应时间")); rgb_dlg->GetDlgItem(SwitchBtnSet)->SetWindowText(_T("设置")); } else if(language == english)//在这里边执行时正确!!!!!!!!!!!!! { rgb_dlg->GetDlgItem(PercentOfPass)->SetWindowText(_T("Percent Of Pass")); rgb_dlg->GetDlgItem(Pass)->SetWindowText(_T("Test Amount")); rgb_dlg->GetDlgItem(RGBValue)->SetWindowText(_T("RGB Value")); rgb_dlg->GetDlgItem(Score)->SetWindowText(_T("Score")); rgb_dlg->GetDlgItem(RespondTime)->SetWindowText(_T("Respond Time")); rgb_dlg->GetDlgItem(SwitchBtnSet)->SetWindowText(_T("Set")); } else { MessageBox(L"IDD_DIALOG1 LanguageSet error",L"error",MB_OKCANCEL); //错误提示 } } else { MessageBox(L"Switchbtn error",L"error",MB_OKCANCEL); //错误提示 } }




    2016年11月19日 7:20