Hi everyone.
I've got a problem using the month/calendar control in my dialog based app (running on W2K).
If I include a calendar control in my app's main dialog and link it to a CTime member variable, everything is fine.
If I place a calendar control in a dialog which I show after the user clicks a button in the main dialog,
the calendar control in this 2nd dialog will not correctly retrieve the selected date.
Here's the code for my modal dialog which is shown when the user clicks a button on the main dialog:

CalenderCtrlTestDlg1::CalenderCtrlTestDlg1(CWnd* pParent /*=NULL*/)
: CDialog(CalenderCtrlTestDlg1::IDD, pParent)
{
//{{AFX_DATA_INIT(CalenderCtrlTestDlg1)
m_Calendar1 = 0;
//}}AFX_DATA_INIT
}


void CalenderCtrlTestDlg1:oDataExchange(CDataExchange* pDX)
{
CDialog:oDataExchange(pDX);
//{{AFX_DATA_MAP(CalenderCtrlTestDlg1)
DDX_MonthCalCtrl(pDX, IDC_MONTHCALENDAR1, m_Calendar1);
//}}AFX_DATA_MAP
}


BEGIN_MESSAGE_MAP(CalenderCtrlTestDlg1, CDialog)
//{{AFX_MSG_MAP(CalenderCtrlTestDlg1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CalenderCtrlTestDlg1 message handlers

void CalenderCtrlTestDlg1::OnOK()
{
// TODO: Add extra validation here
UpdateData(TRUE);
CString c1;
CString c2;
CMonthCalCtrl * pCal2 = (CMonthCalCtrl*) GetDlgItem(IDC_MONTHCALENDAR2);
c1 = m_Calendar1.Format("%d.%m.%Y ");
CTime c2Time;
pCal2->GetCurSel(c2Time);
c2 = c2Time.Format(" %d.%m.%Y");
MessageBox(c1 + c2);
CDialog::OnOK();
}

BOOL CalenderCtrlTestDlg1::OnInitDialog()
{
CDialog::OnInitDialog();
m_Calendar1 = CTime::GetCurrentTime();
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}





If I don't change the date in the calendar control, the MessageBox shows the correct information.
If I choose the next day (i.e. "tomorrow"), the date shown in the messagebox is a date in 2006!
I'm really stumped here as to what's going on. Any help will be greatly appreciated.


Please rate my answer, whether good or bad, so I can improve the answers I give. Thanks!