CMonthCalCtrl returns wrong date
-
Hello all, I created a Month calendar control into my form, and I want to use it as a date picker, so when the user selects a date, I will fill other CEdit controls with the date selected. But I realize that within MCN_SELECT, the value associated with my Calendar Control, gets the wrong date. void CPlanmView::OnSelectMonthcalendar1(NMHDR* pNMHDR, LRESULT* pResult) { // Users Selects a Date, so MCN_SELECT triggers this. // User selected October 31, 2003 but returns // Feb,10,2004 *pResult = 0; UpdateData(); m_DayPlm.Format("%d",m_CalendarVal.GetDay()); m_MonthPlm.Format("%d",m_CalendarVal.GetMonth()); m_YearPlm.Format("%d",m_CalendarVal.GetYear()); UpdateData(FALSE); } I have also seen the sample provided in the msdn, and it has the same problem, for this control. Any Ideas on how to workaround this issue. Best, -Alfredo
-
Hello all, I created a Month calendar control into my form, and I want to use it as a date picker, so when the user selects a date, I will fill other CEdit controls with the date selected. But I realize that within MCN_SELECT, the value associated with my Calendar Control, gets the wrong date. void CPlanmView::OnSelectMonthcalendar1(NMHDR* pNMHDR, LRESULT* pResult) { // Users Selects a Date, so MCN_SELECT triggers this. // User selected October 31, 2003 but returns // Feb,10,2004 *pResult = 0; UpdateData(); m_DayPlm.Format("%d",m_CalendarVal.GetDay()); m_MonthPlm.Format("%d",m_CalendarVal.GetMonth()); m_YearPlm.Format("%d",m_CalendarVal.GetYear()); UpdateData(FALSE); } I have also seen the sample provided in the msdn, and it has the same problem, for this control. Any Ideas on how to workaround this issue. Best, -Alfredo
I just found the answer for this problem Microsoft Knowledge Base Article - 235355 I post it here for reference in case somebody else has to deal with this. The Microsoft article says this behaviour is by design, and SYSTEMTIME should be used instead of CTime class Best, Alfredo