Hello,
We are using custom data provider for calendar control.
Flow is below:
From View class
void fun1() { CXTPCalendarView* pView = GetCalendarCtrl().GetActiveView(); if (pView && pView->GetViewType() != xtpCalendarWeekView) { GetCalendarCtrl().SwitchActiveView(xtpCalendarWeekView); } }
SwitchActiveView calls DoRetrieveDayEvents
CXTPCalendarEventsPtr CCalendarDataProviderSQL::DoRetrieveDayEvents(COleDateTime dtDay) { ----------------------------------
/*CXTPCalendarEventsPtr ptrEvents; Define in .h file as member variable of class*/
ptrEvents = new CXTPCalendarEvents(); pView->GetEventsFromWeekData(ptrEvents); return ptrEvents; }
we are calling views function from "DoRetrieveDayEvents()" who retrive the data from our database and add data as events Please note that we are taking CXTPCalendarEventsPtr input parameter as a reference.
void MyView::GetEventsFromWeekData(CXTPCalendarEventsPtr& ptrEvents) { //Retrive data for week
for(i=0;i<7;i++) { Code to fetch data... //Add data as event. m_pCalendar = &GetCalendarCtrl(); pCalendarData = m_pCalendar->GetDataProvider();
ptrEvent = pCalendarData->CreateNewEvent(); ptrEvent->SetStartTime(evntStTime); ptrEvent->SetEndTime(evntEndTime); ptrEvent->SetSubject(strSubject); if (ptrEvent) { ptrEvents->Add(ptrEvent); } }//For loop ends here }
ISSUE: Application getting crash in file name: XTPCalendarViewDay.h function name: virtual void Populate(COleDateTime dtDayDate) Crash at: if (dtDayDate < CXTPCalendarUtils::ResetTime(pEvent->GetStartTime()) || dtDayDate > CXTPCalendarUtils::ResetTime(pEvent->GetEndTime()) ) { ASSERT(FALSE); TRACE(_T("ERROR data: Day: %s EVENT {%s - %s} \n"), (LPCTSTR)dtDayDate.Format(_T("#%Y-%m-%d#")), (LPCTSTR)CXTPCalendarUtils::ResetTime(pEvent->GetStartTime()).Format(_T("#%Y-%m-%d#")), (LPCTSTR)CXTPCalendarUtils::ResetTime(pEvent->GetEndTime()).Format(_T("#%Y-%m-%d#")) ); }
I had added 3 days data, but after ignoring the crash, it show me first day of week data only.
Please help me out in this.
Thanks, Kumar
|