Basic Steps to use Calendar Control in Dialog App |
Post Reply |
Author | |
solo
Groupie Joined: 10 November 2007 Status: Offline Points: 17 |
Post Options
Thanks(0)
Posted: 25 April 2012 at 5:36am |
Hi,
After searching the forum for some basic set of instructions that can be followed by the users who want to use CXTPCalendarControl in Dialog based application, I ended up posting this request. I am sure this is not some thing huge and any experienced developer of Codejock Support can write the steps in few minutes. Please do consider the fact that this is extremely important and seems like a missing part. I faced the below given problems when I tried to create a Calendar Control. 1. Creating Calendar control was very easy. 2. Adding CaptionBar control to existing Calendar control was very difficult. First ASSERT was called when CRect size was not set to 0,0,0,0. Then after so much difficult I was able to link the caption bar control with calendar control and display it. 3. I had/have no idea which objects to associate with calendar control or which classes require implementation because some times, selecting "Work Week" radio button from "Week" options in caption bar control crashes application, and/or clicking "Day" on caption bar changes the background color to red, and/or clicking any hour from hours column in the left crashes the application. 4. Changing active view of calendar control also crashes the application. Please find the code snippet below: -------------------------------------------------- CXTPResizeDialog::OnInitDialog(); // Get client rect CXTPClientRect rcClient(this); // Create calendar control m_ccCalendar.m_bHideCaptionBar = FALSE; CXTPWindowRect rmsMyTasks(CWnd::FromHandle(m_msMyTasks.GetSafeHwnd())); ScreenToClient(&rmsMyTasks); CXTPWindowRect rmlbMyTasks(CWnd::FromHandle(m_mlbMyTasks.GetSafeHwnd())); ScreenToClient(&rmlbMyTasks); CRect rcCalendar(rcClient); rcCalendar.top = rmsMyTasks.top - 5; rcCalendar.left = rmlbMyTasks.right + 30; rcCalendar.bottom = rmlbMyTasks.bottom + 7; rcCalendar.right -= 20; // Create Calendar CaptionBar Control if (!m_cccCalendarCaption.Create(WS_CHILD | WS_TABSTOP, CRect(0, 0, 0, 0), this, XTP_ID_CALENDARCAPTIONBAR_CONTROL)) { TRACE(_T("Failed to create Calendar Caption Bar control window\n")); } // Create Calendar Control if (!m_ccCalendar.Create(WS_CHILD | WS_TABSTOP | WS_VISIBLE, rcCalendar, this, XTP_ID_CALENDAR_CONTROL) ) { TRACE(_T("Failed to create Calendar control window\n")); } else { int nScrollBarWidth = 0; // Add Calendar resources CXTPCalendarView* pView = m_ccCalendar.GetActiveView(); if (pView) { pView->SetResources(&m_crCalendatResources); } // Attach calendar control if (m_cccCalendarCaption.GetSafeHwnd()) { CRect rcCalendar; m_ccCalendar.GetWindowRect(&rcCalendar); ScreenToClient(&rcCalendar); CRect rcCaptionBar = m_cccCalendarCaption.CalcMinRect(FALSE); rcCaptionBar.MoveToXY(rcCalendar.TopLeft()); rcCaptionBar.right = rcCalendar.right; rcCalendar.top = rcCaptionBar.bottom; m_ccCalendar.MoveWindow(&rcCalendar); BOOL b = m_cccCalendarCaption.IsUseOneLine(); m_cccCalendarCaption.ShowWindow(SW_SHOW); m_cccCalendarCaption.GetTheme()->AttachCalendar(&m_ccCalendar); m_cccCalendarCaption.UseOneLine(b); m_cccCalendarCaption.MoveWindow(&rcCaptionBar); //m_cccCalendarCaption.EnableTimeline(FALSE); } // Set calendar control options CXTPCalendarOptions* pOptions = m_ccCalendar.GetCalendarOptions(); if (pOptions) { // pOptions->bDayView_TimeScaleShowMinutes = TRUE; pOptions->OnOptionsChanged(); } // Set calendar theme CXTPCalendarThemeOffice2007* pTheme2007 = new CXTPCalendarThemeOffice2007(); if (pTheme2007) { m_ccCalendar.SetTheme(pTheme2007); UINT arIDs[5]; arIDs[0] = (UINT)xtpCalendarEventIconIDReminder; arIDs[1] = (UINT)xtpCalendarEventIconIDOccurrence; arIDs[2] = (UINT)xtpCalendarEventIconIDException; arIDs[3] = (UINT)xtpCalendarEventIconIDMeeting; arIDs[4] = (UINT)xtpCalendarEventIconIDPrivate; pTheme2007->GetCustomIconsList()->SetIcons(XTP_IDB_CALENDAR_EVENT_GLYPHS, arIDs, 5, CSize(16, 11), xtpImageNormal); //m_ccCalendar.EnableMarkup(TRUE); //pTheme2007->SetAskItemTextFlags(-1); } // Set calendar view //m_ccCalendar.SwitchActiveView(xtpCalendarWorkWeekView); -------------------------------------------------- I hope some one will give this question a try soon. Thank you |
|
solo
Groupie Joined: 10 November 2007 Status: Offline Points: 17 |
Post Options
Thanks(0)
|
To add more, I reduced the code (given below) and the control is almost stable now. Still I will appreciate if some one can provide a small tutorial, specially linking with outlook to import its appointments.
---------------------------------------------------------- CXTPResizeDialog::OnInitDialog(); // Get client rect CXTPClientRect rcClient(this); // Create calendar control m_ccCalendar.m_bHideCaptionBar = FALSE; CXTPWindowRect rmsMyTasks(CWnd::FromHandle(m_msMyTasks.GetSafeHwnd())); ScreenToClient(&rmsMyTasks); CXTPWindowRect rmlbMyTasks(CWnd::FromHandle(m_mlbMyTasks.GetSafeHwnd())); ScreenToClient(&rmlbMyTasks); CRect rcCalendar(rcClient); rcCalendar.top = rmsMyTasks.top - 5; rcCalendar.left = rmlbMyTasks.right + 30; rcCalendar.bottom = rmlbMyTasks.bottom + 7; rcCalendar.right -= 20; // Create Calendar CaptionBar Control if (!m_cccCalendarCaption.Create(WS_CHILD | WS_TABSTOP, CRect(0, 0, 0, 0), this, XTP_ID_CALENDARCAPTIONBAR_CONTROL)) { TRACE(_T("Failed to create Calendar Caption Bar control window\n")); } // Create Calendar Control if (!m_ccCalendar.Create(WS_CHILD | WS_TABSTOP | WS_VISIBLE, rcCalendar, this, XTP_ID_CALENDAR_CONTROL) ) { TRACE(_T("Failed to create Calendar control window\n")); } else { // Attach calendar control if (m_cccCalendarCaption.GetSafeHwnd()) { CRect rcCalendar; m_ccCalendar.GetWindowRect(&rcCalendar); ScreenToClient(&rcCalendar); CRect rcCaptionBar = m_cccCalendarCaption.CalcMinRect(FALSE); rcCaptionBar.MoveToXY(rcCalendar.TopLeft()); rcCaptionBar.right = rcCalendar.right; rcCalendar.top = rcCaptionBar.bottom; m_ccCalendar.MoveWindow(&rcCalendar); BOOL b = m_cccCalendarCaption.IsUseOneLine(); m_cccCalendarCaption.ShowWindow(SW_SHOW); m_cccCalendarCaption.GetTheme()->AttachCalendar(&m_ccCalendar); m_cccCalendarCaption.UseOneLine(b); m_cccCalendarCaption.MoveWindow(&rcCaptionBar); } // Set calendar theme CXTPCalendarThemeOffice2007* pTheme2007 = new CXTPCalendarThemeOffice2007(); if (pTheme2007) { UINT arIDs[5]; arIDs[0] = (UINT)xtpCalendarEventIconIDReminder; arIDs[1] = (UINT)xtpCalendarEventIconIDOccurrence; arIDs[2] = (UINT)xtpCalendarEventIconIDException; arIDs[3] = (UINT)xtpCalendarEventIconIDMeeting; arIDs[4] = (UINT)xtpCalendarEventIconIDPrivate; pTheme2007->GetCustomIconsList()->SetIcons(XTP_IDB_CALENDAR_EVENT_GLYPHS, arIDs, 5, CSize(16, 11), xtpImageNormal); pTheme2007->SetAskItemTextFlags(-1); m_ccCalendar.SetTheme(pTheme2007); } } ----------------------------------------------------------
|
|
solo
Groupie Joined: 10 November 2007 Status: Offline Points: 17 |
Post Options
Thanks(0)
|
I will appreciate if some one can spare some time to share his/her knowledge.
Thanks
|
|
SuperMario
Admin Group Joined: 14 February 2004 Status: Offline Points: 18057 |
Post Options
Thanks(0)
|
Just curious if you looked at the Calendar demo sample because it shows h ow to do all of what you ask. The outlook provider is the MAPI provider.
|
|
Steve Reilly
Newbie Joined: 31 May 2013 Location: Canada Status: Offline Points: 1 |
Post Options
Thanks(0)
|
Hi
I have to agree, a simple Calendar Demo in a dialog or CFormView showing the minimum needed to get the control up and going would be very helpful. The current demos are too complex for simple evaluation. |
|
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 |