// 还原默认值 void COptions::Ontacitly() { // TODO: Add your control notification handler code here CMyDlg *pWnd = (CMyDlg*)AfxGetMainWnd();//AfxGetApp(); if(pWnd->dose_for_oneday > 0.0f) { CString str; pWnd->CountDose(); str.Format("%.3f",pWnd->_24HourBase); //%50 SetDlgItemText(IDC_DAYBASIC,str); pWnd->dose_before_meal.breakfast = pWnd->dose_for_oneday * 20.0f / 100.0f;//%20 str.Format("%.3f",pWnd->dose_before_meal.breakfast); SetDlgItemText(IDC_sBreakfast,str); pWnd->dose_before_meal.lunch = pWnd->dose_for_oneday * 15.0f / 100.0f;//%15 str.Format("%.3f",pWnd->dose_before_meal.lunch); SetDlgItemText(IDC_sLunch,str); pWnd->dose_before_meal.supper = pWnd->dose_for_oneday * 15.0f / 100.0f;//%15 str.Format("%.3f",pWnd->dose_before_meal.supper); SetDlgItemText(IDC_sSupper,str); pWnd->Time_BloodSugar = 120 * 1000; str.Format("%d",2); SetDlgItemText(IDC_Time_Interval,str); if(pWnd->WriteToFile(pWnd) == TRUE) MessageBox("设置成功!"); } else MessageBox("请先设置\"一日总量\"!!!"); }
void COptions::OnOK() { // TODO: Add extra validation here UpdateData(TRUE); //根据用户选择的设置输入的值 // float insulin_residue; // 胰岛素剩余剂量 // float dose_for_oneday; // 一天注入胰岛素的剂量 // float start_found_dose; // 胰岛素开始基础量 CString str; str.Format("%.3f",m_GetFval); CMyDlg *pWnd = (CMyDlg*)AfxGetMainWnd();//AfxGetApp();//获取父窗口 switch(m_ChooseIndex) { case 0: pWnd->insulin_residue += m_GetFval;// 添加胰岛素剩余剂量 str.Format("%.3f",pWnd->insulin_residue); SetDlgItemText(IDC_INSULINleft,str); break; case 1: pWnd->dose_for_oneday = m_GetFval;// 一天注入胰岛素的剂量 pWnd->CountDose(); SetDlgItemText(IDC_ForDay,str); pWnd->SetDlgItemText(IDC_mBISIC,str); break; case 2: pWnd->_24HourBase = pWnd->start_found_dose = m_GetFval; SetDlgItemText(IDC_DAYBASIC,str);// 胰岛素开始基础量 break; case 3: pWnd->dose_before_meal.breakfast = m_GetFval; SetDlgItemText(IDC_sBreakfast,str); break; case 4://MessageBox("设置4!"); pWnd->dose_before_meal.lunch = m_GetFval; SetDlgItemText(IDC_sLunch,str); break; case 5: pWnd->dose_before_meal.supper = m_GetFval; SetDlgItemText(IDC_sSupper,str); break; case 6: if(m_GetFval < 1.0) MessageBox("请输入一个大于 1 的数字!"); else { pWnd->Time_BloodSugar = (int)m_GetFval * 60 * 1000; if(pWnd->isStart == TRUE) { pWnd->KillTimer(T_CHECKBLOOD); pWnd->SetTimer(T_CHECKBLOOD,pWnd->Time_BloodSugar,NULL); } str.Format("%d",(int)m_GetFval); SetDlgItemText(IDC_Time_Interval,str); //MessageBox("设置成功!!"); } break; default: MessageBox("请选择一个选项设置!!"); } if(m_ChooseIndex >= 0 && m_ChooseIndex < 6) { // pWnd->WriteToFile(pWnd);//按"返回"再写入 UpdateData(FALSE); SetDlgItemText(IDC_GetDataText,""); GetDlgItem(IDC_GetDataText)->SetFocus(); } // CDialog::OnOK();//不调用 }