home *** CD-ROM | disk | FTP | other *** search
- #include "stdafx.h"
- #include "dtset.h"
- #include "DtsetDlg.h"
- #include "dtime.h"
-
-
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- CDtsetDlg::CDtsetDlg(CWnd* pParent /*=NULL*/)
- : CDialog(CDtsetDlg::IDD, pParent)
- {
- //{{AFX_DATA_INIT(CDtsetDlg)
- m_nGDay = 0;
- m_lGYear = 0;
- m_nJDay = 0;
- m_lJYear = 0;
- //}}AFX_DATA_INIT
- m_nGMonth = 1;
- m_nJMonth = 1;
- }
-
-
- void CDtsetDlg::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
-
- //{{AFX_DATA_MAP(CCDateDOMPage)
- DDX_Control(pDX, IDC_SPINJYEAR, m_SpinJYear);
- DDX_Control(pDX, IDC_SPINJDAY, m_SpinJDay);
- DDX_Control(pDX, IDC_SPINGYEAR, m_SpinGYear);
- DDX_Control(pDX, IDC_SPINGDAY, m_SpinGDay);
- DDX_Text(pDX, IDC_JDAY, m_nJDay);
- DDX_Text(pDX, IDC_JYEAR, m_lJYear);
- DDX_Text(pDX, IDC_GDAY, m_nGDay);
- DDX_Text(pDX, IDC_GYEAR, m_lGYear);
- //}}AFX_DATA_MAP
-
- if (pDX->m_bSaveAndValidate)
- {
- DDX_CBIndex(pDX, IDC_GMONTH, (int&) m_nGMonth);
- m_nGMonth++;
- DDX_CBIndex(pDX, IDC_JMONTH, (int&) m_nJMonth);
- m_nJMonth++;
- }
- else
- {
- int nGMonthIndex = m_nGMonth-1;
- DDX_CBIndex(pDX, IDC_GMONTH, nGMonthIndex);
- int nJMonthIndex = m_nJMonth-1;
- DDX_CBIndex(pDX, IDC_JMONTH, nJMonthIndex);
- }
-
- pDX->PrepareEditCtrl(IDC_JDAY);
- DDV_MinMaxUInt(pDX, m_nJDay, 1, CDate::DaysInMonth(m_nJMonth, m_lJYear));
- pDX->PrepareEditCtrl(IDC_GDAY);
- DDV_MinMaxUInt(pDX, m_nGDay, 1, CDate::DaysInMonth(m_nGMonth, m_lGYear));
- }
-
-
- BEGIN_MESSAGE_MAP(CDtsetDlg, CDialog)
- //{{AFX_MSG_MAP(CDtsetDlg)
- //}}AFX_MSG_MAP
- END_MESSAGE_MAP()
-
-
- void CDtsetDlg::OnOK()
- {
- CDialog::OnOK();
-
- //Store the new settings from the registry
- CDate::SetEndJulianCalendar(m_lJYear, m_nJMonth, (WORD) m_nJDay);
- CDate::SetBeginGregorianCalendar(m_lGYear, m_nGMonth, (WORD) m_nGDay);
- }
-
-
- BOOL CDtsetDlg::OnInitDialog()
- {
- //Add the month strings
- CComboBox* pMonthCombo1 = (CComboBox*) GetDlgItem(IDC_GMONTH);
- CComboBox* pMonthCombo2 = (CComboBox*) GetDlgItem(IDC_JMONTH);
- ASSERT(pMonthCombo1);
- ASSERT(pMonthCombo2);
- for (WORD i=1; i<13; i++)
- {
- pMonthCombo1->AddString(CDate::GetFullStringMonth(i));
- pMonthCombo2->AddString(CDate::GetFullStringMonth(i));
- }
-
- //retreive the default settings from the registry
- CDate::GetEndJulianCalendar(m_lJYear, m_nJMonth, (WORD&) m_nJDay);
- CDate::GetBeginGregorianCalendar(m_lGYear, m_nGMonth, (WORD&) m_nGDay);
-
- //Call up to the parent
- CDialog::OnInitDialog();
-
- //Set the ranges for the spin controls
- m_SpinJYear.SetRange(UD_MINVAL, UD_MAXVAL);
- m_SpinJDay.SetRange(1, 31);
- m_SpinGYear.SetRange(UD_MINVAL, UD_MAXVAL);
- m_SpinGDay.SetRange(1, 31);
-
- return TRUE;
- }
-