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.

132 lines
3.6 KiB

  1. // RatExprD.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "cnfgprts.h"
  5. #include "RatExprD.h"
  6. #ifdef _DEBUG
  7. #define new DEBUG_NEW
  8. #undef THIS_FILE
  9. static char THIS_FILE[] = __FILE__;
  10. #endif
  11. /////////////////////////////////////////////////////////////////////////////
  12. // CRatExpireDlg dialog
  13. //--------------------------------------------------------------------------
  14. CRatExpireDlg::CRatExpireDlg(CWnd* pParent /*=NULL*/)
  15. : CDialog(CRatExpireDlg::IDD, pParent),
  16. m_day( 0 ),
  17. m_month( 0 ),
  18. m_year( 0 )
  19. {
  20. //{{AFX_DATA_INIT(CRatExpireDlg)
  21. // NOTE: the ClassWizard will add member initialization here
  22. //}}AFX_DATA_INIT
  23. }
  24. //--------------------------------------------------------------------------
  25. void CRatExpireDlg::DoDataExchange(CDataExchange* pDX)
  26. {
  27. CDialog::DoDataExchange(pDX);
  28. //{{AFX_DATA_MAP(CRatExpireDlg)
  29. DDX_Control(pDX, IDC_MSACALCTRL, m_calendar);
  30. //}}AFX_DATA_MAP
  31. }
  32. //--------------------------------------------------------------------------
  33. BEGIN_MESSAGE_MAP(CRatExpireDlg, CDialog)
  34. //{{AFX_MSG_MAP(CRatExpireDlg)
  35. //}}AFX_MSG_MAP
  36. END_MESSAGE_MAP()
  37. /////////////////////////////////////////////////////////////////////////////
  38. // CRatExpireDlg message handlers
  39. //--------------------------------------------------------------------------
  40. BOOL CRatExpireDlg::IsSystemDBCS( void )
  41. {
  42. WORD wPrimaryLangID = PRIMARYLANGID( GetSystemDefaultLangID() );
  43. return ( wPrimaryLangID == LANG_JAPANESE ||
  44. wPrimaryLangID == LANG_CHINESE ||
  45. wPrimaryLangID == LANG_KOREAN );
  46. }
  47. //--------------------------------------------------------------------------
  48. BOOL CRatExpireDlg::OnInitDialog( )
  49. {
  50. SYSTEMTIME time;
  51. // get the base class going
  52. BOOL f = CDialog::OnInitDialog();
  53. // set up the calendar in DBCS mode as appropriate - suggested by the japanese guys
  54. if ( IsSystemDBCS() )
  55. {
  56. m_calendar.SetDayLength( 0 ); // 0: localized one
  57. m_calendar.SetMonthLength( 0 ); // 0: localized one
  58. m_calendar.SetDayFont( NULL ); // use default
  59. m_calendar.SetGridFont( NULL ); // use default
  60. m_calendar.SetTitleFont( NULL ); // use default
  61. }
  62. //
  63. // Background colour looks weird if the dialog
  64. // is not gray
  65. //
  66. m_calendar.SetBackColor(GetSysColor(COLOR_BTNFACE));
  67. // now tell the calendar to focus on one year from today, or the supplied date
  68. // if there is one
  69. if ( m_year )
  70. {
  71. m_calendar.SetYear( m_year );
  72. m_calendar.SetMonth( m_month );
  73. m_calendar.SetDay( m_day );
  74. }
  75. else
  76. {
  77. // the default case - use one year from today
  78. GetLocalTime( &time );
  79. m_calendar.SetYear( time.wYear + 1 );
  80. m_calendar.SetMonth( time.wMonth );
  81. m_calendar.SetDay( time.wDay );
  82. }
  83. // return the answer
  84. return f;
  85. }
  86. //--------------------------------------------------------------------------
  87. void CRatExpireDlg::OnOK()
  88. {
  89. // get the date
  90. m_day = m_calendar.GetDay();
  91. m_month = m_calendar.GetMonth();
  92. m_year = m_calendar.GetYear();
  93. // test if nothing is selected - check if the year is 0
  94. if ( m_year == 0 )
  95. {
  96. AfxMessageBox(IDS_NO_DATE_SELECTED);
  97. return;
  98. }
  99. // put it into a CTime so we can compare
  100. CTime timeCal(m_year,m_month,m_day,12,0,0);
  101. // compare
  102. if ( timeCal < CTime::GetCurrentTime() )
  103. {
  104. if ( AfxMessageBox(IDS_EXPIRE_SET_PAST,MB_YESNO) == IDNO )
  105. return;
  106. }
  107. // let the dialog close
  108. CDialog::OnOK();
  109. }