Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

227 lines
3.5 KiB

  1. /*++
  2. Copyright (c) 1994-1998 Microsoft Corporation
  3. Module Name :
  4. seldate.cpp
  5. Abstract:
  6. Date selector dialog
  7. Author:
  8. Ronald Meijer (ronaldm)
  9. Project:
  10. Internet Services Manager
  11. Revision History:
  12. --*/
  13. //
  14. // Include Files
  15. //
  16. #include "stdafx.h"
  17. #include "w3scfg.h"
  18. #include "seldate.h"
  19. #ifdef _DEBUG
  20. #define new DEBUG_NEW
  21. #undef THIS_FILE
  22. static char THIS_FILE[] = __FILE__;
  23. #endif
  24. CSelDate::CSelDate(
  25. IN CTime tm,
  26. IN CWnd * pParent OPTIONAL
  27. )
  28. /*++
  29. Routine Description:
  30. Date selector dialog constructor
  31. Arguments:
  32. CTime tm,
  33. CWnd * pParent OPTIONAL
  34. Return Value:
  35. None
  36. --*/
  37. : m_tm(tm),
  38. CDialog(CSelDate::IDD, pParent)
  39. {
  40. //{{AFX_DATA_INIT(CSelDate)
  41. //}}AFX_DATA_INIT
  42. }
  43. void
  44. CSelDate::DoDataExchange(
  45. IN CDataExchange * pDX
  46. )
  47. /*++
  48. Routine Description:
  49. Initialise/Store Control Data
  50. Arguments:
  51. CDataExchange * pDX : Data exchange object
  52. Return Value:
  53. None
  54. --*/
  55. {
  56. CDialog::DoDataExchange(pDX);
  57. //{{AFX_DATA_MAP(CSelDate)
  58. DDX_Control(pDX, IDC_MSACALCTRL, m_cal);
  59. //}}AFX_DATA_MAP
  60. }
  61. //
  62. // Message Map
  63. //
  64. BEGIN_MESSAGE_MAP(CSelDate, CDialog)
  65. //{{AFX_MSG_MAP(CSelDate)
  66. //}}AFX_MSG_MAP
  67. END_MESSAGE_MAP()
  68. BOOL
  69. IsSystemDBCS()
  70. /*++
  71. Routine Description:
  72. Helper function to determine if we're running on a DBCS function
  73. Arguments:
  74. None
  75. Return Value:
  76. TRUE if we're on a DBCS system, FALSE otherwise.
  77. --*/
  78. {
  79. WORD wPrimaryLangID = PRIMARYLANGID(GetSystemDefaultLangID());
  80. return wPrimaryLangID == LANG_JAPANESE
  81. || wPrimaryLangID == LANG_CHINESE
  82. || wPrimaryLangID == LANG_KOREAN;
  83. }
  84. //
  85. // Message Handlers
  86. //
  87. // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  88. BOOL
  89. CSelDate::OnInitDialog()
  90. /*++
  91. Routine Description:
  92. WM_INITDIALOG handler. Initialize the dialog.
  93. Arguments:
  94. None.
  95. Return Value:
  96. TRUE if focus is to be set automatically, FALSE if the focus
  97. is already set.
  98. --*/
  99. {
  100. CDialog::OnInitDialog();
  101. //
  102. // Note: SetMonth before SetDay, otherwise the 31 is not
  103. // considered a valid date.
  104. //
  105. m_cal.SetBackColor(GetSysColor(COLOR_BTNFACE));
  106. m_cal.SetYear((SHORT)m_tm.GetYear());
  107. m_cal.SetMonth((SHORT)m_tm.GetMonth());
  108. m_cal.SetDay((SHORT)m_tm.GetDay());
  109. if (IsSystemDBCS())
  110. {
  111. //
  112. // Set localisation defaults (override dlginit settings,
  113. // inserted by the msdev dialog editor) This is necessary
  114. // to override a problem in DBCS version of calendar OCX.
  115. //
  116. m_cal.SetDayLength(0);
  117. m_cal.SetMonthLength(0);
  118. m_cal.SetDayFont(NULL);
  119. m_cal.SetGridFont(NULL);
  120. m_cal.SetTitleFont(NULL);
  121. }
  122. return TRUE;
  123. }
  124. void
  125. CSelDate::OnOK()
  126. /*++
  127. Routine Description:
  128. 'OK' button handler
  129. Arguments:
  130. None
  131. Return Value:
  132. None
  133. --*/
  134. {
  135. int year = m_cal.GetYear();
  136. int month = m_cal.GetMonth();
  137. int day = m_cal.GetDay();
  138. int hour = m_tm.GetHour();
  139. int minute = m_tm.GetMinute();
  140. int sec = m_tm.GetSecond();
  141. if (!year || !month || !day)
  142. {
  143. ::AfxMessageBox(IDS_NO_DATE);
  144. return;
  145. }
  146. if (year > 2037 || year < 1970)
  147. {
  148. ::AfxMessageBox(IDS_BAD_DATE);
  149. return;
  150. }
  151. m_tm = CTime(year, month, day, hour, minute, sec);
  152. if (m_tm <= CTime::GetCurrentTime())
  153. {
  154. if (::AfxMessageBox(IDS_WRN_OLD_DATE, MB_YESNO) != IDYES)
  155. {
  156. return;
  157. }
  158. }
  159. CDialog::OnOK();
  160. }