How To switch back in day mode? |
Post Reply |
Author | |
prashant
Senior Member Joined: 19 February 2007 Location: India Status: Offline Points: 165 |
Post Options
Thanks(0)
Posted: 09 April 2008 at 9:32am |
As per shown in the example I added multiple schedules. Now I want to switch back in Day mode/View. How to achieve this?
|
|
prashant
Senior Member Joined: 19 February 2007 Location: India Status: Offline Points: 165 |
Post Options
Thanks(0)
|
Hi Oleg,
We have Day, 2 Days, Week, 2 Weeks, Month and Multi Schedule Views for Calendar. Issue: When we want to go back to "Day" View from "MultiShedule" View, View is not getting changed to DAY View and not getting displayed. Thanks in advance. |
|
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
|
As you probably discovered there's no method illustrated in the samples to revert to the original "day view" mode after using a multiple configuration. However, it is possible. What you need to do is recreate the original calendar resource. When you debug you can see that there is indeed a calendar resource created when you start in day view mode. It has a blank string for name so it doesn't display anything at the top of the calendar. Here is an example of using a new resource when switching to restore day view mode: void CCalendarDoc::OnScheduleSelect() { CSchedDlg dlg; int nDlgRes = (int)dlg.DoModal(); if (nDlgRes == IDOK) { CXTPCalendarControl* pCalendar = GetCalendarCtrl(); if ( dlg.m_pResources->GetCount() ) { pCalendar->SetResources(dlg.m_pResources); pCalendar->Populate(); pCalendar->RedrawControl(); } else { CXTPCalendarResource *pResource = new CXTPCalendarResource(pCalendar); if (!pResource) ASSERT(FALSE); pResource->SetDataProvider(pCalendar->GetDataProvider()); pResource->SetName(_T("")); pCalendar->GetResources()->Add(pResource); for (int i = 0; i < pCalendar->GetResources()->GetCount(); i++ ) { if (pResource->GetName() != _T("") ) pCalendar->GetResources()->RemoveAt(i); } } } There are probably other, better ways of doing this but this works. I tried a couple other approaches which failed and I'm not 100% sure why, but I believe it's due to the way smart pointers are used. A couple of things to avoid: 1. GetResources->RemoveAll() will fail. 2. Maintaining a copy of the original resource and trying to reuse it will fail and it's scarcely worth the effort. Hope this helps you out. It takes some digging to see exactly what the system expects. Maybe CJ can include the methodology in their sample so others aren't stuck on this. |
|
KumarCJ
Groupie Joined: 02 April 2007 Location: India Status: Offline Points: 96 |
Post Options
Thanks(0)
|
Hi,
I have one doubt, I implemented two modes 1) Multischedule and 2) Day
In multischedule mode I can see newly added scedules (Columns) but when I try to switch back to Day mode Columns remains as it is.
My question is
How to remove schedules while switching back to Day mode?
I tried following code but CAlendar cntrol is turning whole RED
Code:-
CXTPCalendarControl* pCalendarCtrl = &this->GetCalendarCtrl();
CXTPCalendarData * pData = pCalendarCtrl->GetDataProvider(); if (!pData)
return; pSchedules = pData->GetSchedules();
if (!pSchedules)
return; int iCnt = pCalendarCtrl->GetResources()->GetCount(); // Here I am getting proper column/schedule count (2)
for (int i = 0; i < iCnt; i++ )
{ pCalendarCtrl->GetResources()->RemoveAt(0);
} Thanks in advance.
|
|
Algae
Senior Member Joined: 08 January 2007 Location: United States Status: Offline Points: 217 |
Post Options
Thanks(0)
|
Not 100% sure of what's going on based on your code, but I did not see in your code where you set the original provider again.
Set new (same as original) provider: pCalendar->SetDataProvider(GetDataProvider(), FALSE); where GetDataProvider() returns your original provider such as SQLDataProvider etc. You have to set the new (old!) provider in order to repopulate. |
|
AndreiM
Moderator Group Joined: 18 August 2007 Status: Offline Points: 132 |
Post Options
Thanks(0)
|
Hello,
You are right.
CXTPCalendarControl::SetDataProvider is used to easy set a single resource.
CXTPCalendarControl::SetResources is used to set one or few resources.
Calendar is multi-scheduled in the kernel. There is no special single resource mode.
If you set only one resource - it just does not show resource header (name) by default .
KumarCJ in his code remove all resources and does not add one.
GetDataProvider() simply return first resource data provider.
FYI. Each resource may have own separate data provider as far as one data provider may be used for many resources.
|
|
Post Reply | |
Tweet
|
Forum Jump | Forum Permissions You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |