MFC,VC,关闭对话框时出错,对话框关闭后又弹出一个新的,为什么?

2025-04-04 16:44:36
推荐回答(1个)
回答1:

这是个模态对话框,你执行了两次对话框的打开,所以才弹出两次 ,分别在程序的第二行和第十二行
可以改成
NEW_USER dlg;
if(dlg.DoModal()==IDOK) {
CString str_time;
CTime mytime = CTime::GetCurrentTime();
str_time = mytime.Format("%Y-%m-%d");

CStringstr = "姓名:" + dlg.m_editName +
"\n年龄:" + dlg.m_editAge
+ "\n性别:" + dlg.m_editGender
+ "\n诊号:" + dlg.m_editClinicID
+ "\n建档时间:" + str_time
+ "\n";
MessageBox(str);
}