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
|