bool wxCalendarCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) { NMHDR* hdr = (NMHDR *)lParam; switch ( hdr->code ) { case MCN_SELCHANGE: { // we need to update m_date first, before calling the user code // which expects GetDate() to return the new date const wxDateTime dateOld = m_date; const NMSELCHANGE * const sch = (NMSELCHANGE *)lParam; m_date.SetFromMSWSysDate(sch->stSelStart); // changing the year or the month results in a second dummy // MCN_SELCHANGE event on this system which doesn't really // change anything -- filter it out if ( m_date != dateOld ) { if ( GenerateAllChangeEvents(dateOld) ) { // month changed, need to update the holidays if we use // them if ( SetHolidayAttrs() ) UpdateMarks(); } } } break; case MCN_GETDAYSTATE: { const NMDAYSTATE * const ds = (NMDAYSTATE *)lParam; for ( int i = 0; i < ds->cDayState; i++ ) { ds->prgDayState[i] = m_marks | m_holidays; } } break; default: return wxCalendarCtrlBase::MSWOnNotify(idCtrl, lParam, result); } *result = 0; return true; }
bool wxCalendarCtrl::MSWOnNotify(int idCtrl, WXLPARAM lParam, WXLPARAM *result) { NMHDR* hdr = (NMHDR *)lParam; switch ( hdr->code ) { case MCN_SELCHANGE: { // we need to update m_date first, before calling the user code // which expects GetDate() to return the new date const wxDateTime dateOld = m_date; const NMSELCHANGE * const sch = (NMSELCHANGE *)lParam; m_date.SetFromMSWSysDate(sch->stSelStart); // changing the year or the month results in a second dummy // MCN_SELCHANGE event on this system which doesn't really // change anything -- filter it out if ( m_date != dateOld ) { if ( GenerateAllChangeEvents(dateOld) ) { // month changed, need to update the holidays if we use // them SetHolidayAttrs(); UpdateMarks(); } } } break; case MCN_GETDAYSTATE: { const NMDAYSTATE * const ds = (NMDAYSTATE *)lParam; wxDateTime startDate; startDate.SetFromMSWSysDate(ds->stStart); // Ensure we have a valid date to work with. wxDateTime currentDate = m_date.IsValid() ? m_date : startDate; // Set to the start of month for comparison with startDate to // work correctly. currentDate.SetDay(1); for ( int i = 0; i < ds->cDayState; i++ ) { // set holiday/marks only for the "current" month if ( startDate == currentDate ) ds->prgDayState[i] = m_marks | m_holidays; else ds->prgDayState[i] = 0; startDate += wxDateSpan::Month(); } } break; default: return wxCalendarCtrlBase::MSWOnNotify(idCtrl, lParam, result); } *result = 0; return true; }