// 还原默认值 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("请先设置\"一日总量\"!!!"); }
BOOL CMyApp::InitInstance() { if (!AfxSocketInit()) { AfxMessageBox(IDP_SOCKETS_INIT_FAILED); return FALSE; } AfxEnableControlContainer(); // Standard initialization #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif CMyDlg dlg; m_pMainWnd = &dlg; int nResponse = dlg.DoModal(); if (nResponse == IDOK) { } else if (nResponse == IDCANCEL) { } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
BOOL CMyApp::InitInstance() { AfxEnableControlContainer(); // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need. #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif CMyDlg dlg; m_pMainWnd = &dlg; int nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
BOOL CMyThread::InitInstance() { CMyDlg dlg; m_pMainWnd=&dlg; dlg.DoModal(); return TRUE; }
BOOL CMyApp::InitInstance() { SetDialogBkColor(RGB(239,242,242),RGB(50,20,20)); //设置对话框背景和字体颜色 CMyDlg dlg; m_pMainWnd = &dlg; dlg.DoModal(); return FALSE; }
BOOL CMyApp::InitInstance() { // Standard initialization SetDialogBkColor (RGB (250,250,250), RGB ( 0,0,0)); CMyDlg dlg; m_pMainWnd = &dlg; int nResponse = dlg.DoModal(); if (nResponse == IDOK) { } else if (nResponse == IDCANCEL) { } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
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();//不调用 }