WorkplanDlg.cpp
上传用户:miya_hong
上传日期:2008-12-25
资源大小:182k
文件大小:4k
源码类别:

教育系统应用

开发平台:

Visual C++

  1. // WorkplanDlg.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "XieyuyingDB.h"
  5. #include "WorkplanDlg.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CWorkplanDlg dialog
  13. CWorkplanDlg::CWorkplanDlg(CWnd* pParent /*=NULL*/)
  14. : CDialog(CWorkplanDlg::IDD, pParent)
  15. {
  16. //{{AFX_DATA_INIT(CWorkplanDlg)
  17. m_Time1 = 0;
  18. m_Time2 = 0;
  19. m_Time3 = 0;
  20. m_Time4 = 0;
  21. m_wenben = _T("");
  22. //}}AFX_DATA_INIT
  23. }
  24. void CWorkplanDlg::DoDataExchange(CDataExchange* pDX)
  25. {
  26. CDialog::DoDataExchange(pDX);
  27. //{{AFX_DATA_MAP(CWorkplanDlg)
  28. DDX_DateTimeCtrl(pDX, IDC_WORKSTAT_DATETIMEPICKER1, m_Time1);
  29. DDX_DateTimeCtrl(pDX, IDC_WORKSTAT_DATETIMEPICKER2, m_Time2);
  30. DDX_DateTimeCtrl(pDX, IDC_WORKSTAT_DATETIMEPICKER3, m_Time3);
  31. DDX_DateTimeCtrl(pDX, IDC_WORKSTAT_DATETIMEPICKER4, m_Time4);
  32. DDX_Text(pDX, IDC_EDIT1, m_wenben);
  33. //}}AFX_DATA_MAP
  34. }
  35. BEGIN_MESSAGE_MAP(CWorkplanDlg, CDialog)
  36. //{{AFX_MSG_MAP(CWorkplanDlg)
  37. ON_BN_CLICKED(IDC_WORKPLAN_RESET, OnWorkplanReset)
  38. ON_BN_CLICKED(IDC_WORKPLAN_MODIFY, OnWorkplanModify)
  39. ON_WM_CTLCOLOR()
  40. //}}AFX_MSG_MAP
  41. END_MESSAGE_MAP()
  42. /////////////////////////////////////////////////////////////////////////////
  43. // CWorkplanDlg message handlers
  44. void CWorkplanDlg::OnWorkplanReset() 
  45. {
  46. CString cstr[4];
  47. char str[4][9];
  48. int i;
  49. int nHour,nMinute,nSecond; // 时,分,秒
  50. CString strFileName=".\workplan.ini"; // INI文件名
  51. // 读取INI文件
  52. GetPrivateProfileString("WorkPlan", "Time1", "08:00:00", str[0], 9, strFileName);
  53. GetPrivateProfileString("WorkPlan", "Time2", "12:00:00", str[1], 9, strFileName);
  54. GetPrivateProfileString("WorkPlan", "Time3", "14:00:00", str[2], 9, strFileName);
  55. GetPrivateProfileString("WorkPlan", "Time4", "18:00:00", str[3], 9, strFileName);
  56.    
  57. for(i=0; i<4; i++) cstr[i]=str[i];
  58. // 定义四个时间变量并初始化为INI文件中的值
  59. sscanf(cstr[0].Left(2), "%d", &nHour); // 得到时
  60. sscanf(cstr[0].Mid(3,2), "%d", &nMinute); // 得到分
  61. sscanf(cstr[0].Mid(6,2), "%d", &nSecond); // 得到秒
  62. CTime t1(2002,1,1,nHour,nMinute,nSecond); // 初始化t1
  63. sscanf(cstr[1].Left(2), "%d", &nHour); // 得到时
  64. sscanf(cstr[1].Mid(3,2), "%d", &nMinute); // 得到分
  65. sscanf(cstr[1].Mid(6,2), "%d", &nSecond); // 得到秒
  66. CTime t2(2002,1,1,nHour,nMinute,nSecond); // 初始化t2
  67. sscanf(cstr[2].Left(2), "%d", &nHour); // 得到时
  68. sscanf(cstr[2].Mid(3,2), "%d", &nMinute); // 得到分
  69. sscanf(cstr[2].Mid(6,2), "%d", &nSecond); // 得到秒
  70. CTime t3(2002,1,1,nHour,nMinute,nSecond); // 初始化t3
  71. sscanf(cstr[3].Left(2), "%d", &nHour); // 得到时
  72. sscanf(cstr[3].Mid(3,2), "%d", &nMinute); // 得到分
  73. sscanf(cstr[3].Mid(6,2), "%d", &nSecond); // 得到秒
  74. CTime t4(2002,1,1,nHour,nMinute,nSecond); // 初始化t4
  75. // 设置成员变量
  76. m_Time1=t1;
  77. m_Time2=t2;
  78. m_Time3=t3;
  79. m_Time4=t4;
  80. UpdateData(FALSE); // 更新界面数据
  81. }
  82. void CWorkplanDlg::OnWorkplanModify() 
  83. {
  84. CString strFileName=".\workplan.ini"; // INI文件名
  85. UpdateData(); // 更新数据
  86. WritePrivateProfileString("WorkPlan", "Time1",
  87. m_Time1.Format("%H:%M:%S"), strFileName);
  88. WritePrivateProfileString("WorkPlan", "Time2",
  89. m_Time2.Format("%H:%M:%S"), strFileName);
  90. WritePrivateProfileString("WorkPlan", "Time3",
  91. m_Time3.Format("%H:%M:%S"), strFileName);
  92. WritePrivateProfileString("WorkPlan", "Time4",
  93. m_Time4.Format("%H:%M:%S"), strFileName);
  94. WritePrivateProfileString("WorkPlan", "书名",
  95. m_wenben, strFileName);
  96. //CString m_wenben;
  97. //WritePrivateProfileString("WorkPlan", "m_wenben",
  98. // m_wenben, strFileName);
  99. }
  100. BOOL CWorkplanDlg::OnInitDialog() 
  101. {
  102. CDialog::OnInitDialog();
  103. OnWorkplanReset(); // 初始化时间设置
  104. // m_brush.CreateSolidBrush(RGB(5,90,5));
  105. return TRUE;  // return TRUE unless you set the focus to a control
  106.               // EXCEPTION: OCX Property Pages should return FALSE
  107. }
  108. /*HBRUSH CWorkplanDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
  109. {
  110. HBRUSH hbr = (HBRUSH)m_brush;
  111.    
  112. if(nCtlColor==CTLCOLOR_STATIC)
  113. {   pDC->SetBkMode(TRANSPARENT);
  114. return hbr;
  115. }
  116. if(nCtlColor==CTLCOLOR_EDIT)
  117. {  
  118. return NULL;
  119. }
  120. return hbr;
  121. }*/