Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Calendar
  New Posts New Posts RSS Feed - Cell Color in Month View
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Cell Color in Month View

 Post Reply Post Reply
Author
Message
smis View Drop Down
Newbie
Newbie


Joined: 05 January 2007
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote smis Quote  Post ReplyReply Direct Link To This Post Topic: Cell Color in Month View
    Posted: 05 January 2007 at 2:14pm
Is there any way we can change the color of a cell in the Month View.  I need to have three colors to be diaplyed. Say the whole scenario is such that I want to show days for which I have no appointment in red. Days for which I am having Task assigned for the whole day to be displayed in Green and days for which I have task assigned for some hours only to be displayed in yellow.
 
 
 
Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post Posted: 12 January 2007 at 6:13pm

You can do this for Office 2007 theme only.
It has extra customization features.

CalendarThemeOffice2007 object has many parameters like fonts, colors, sizes, etc for each Calendar object (like days, events, headers ...)
Changing these parameters is applied to all objects of such type.

The general idea of dynamic customization that calendar send special notification
  XTP_NC_CALENDAR_BEFORE_DRAW_THEMEOBJECT
which allows you to change drawing parameters for each object separately.

For how to use calendar notifications see: CCalendarDemoView::CCalendarDemoView()

For optimization, this notification is sent only for objects which specified in
BeforeDrawFlags member.
When you set theme, make the following call:    
  pTheme2007->SetBeforeDrawFlags(xtpCalendarBeforeDraw_MonthViewDay);
See also:
    XTPCalendarBeforeDrawThemeObject enum.


Example of code to set day background color:

void CCalendarDemoView::OnBeforeDrawThemeObject(XTP_NOTIFY_CODE Event, WPARAM wParam , LPARAM lParam)
{
  ASSERT(Event == XTP_NC_CALENDAR_BEFORE_DRAW_THEMEOBJECT);
  CXTPCalendarThemeOffice2007* pTheme2007 = DYNAMIC_DOWNCAST(CXTPCalendarThemeOffice2007, GetCalendarCtrl().GetTheme());
  ASSERT(pTheme2007);
  if (!pTheme2007)
    return;

  if (wParam == xtpCalendarBeforeDraw_MonthViewDay)
  {
    CXTPCalendarMonthViewDay* pDay = (CXTPCalendarMonthViewDay*)lParam;
 
    if (pDay->GetDayDate().GetDayOfWeek() == 3)
    {
      pTheme2007->GetMonthViewPartX()->GetDayPartX()->m_clrBackgroundDark = RGB(196, 128, 128);
      pTheme2007->GetMonthViewPartX()->GetDayPartX()->m_clrBackgroundLight = RGB(230, 128, 128);
      pTheme2007->GetMonthViewPartX()->GetDayPartX()->m_clrBackgroundSelected = RGB(128, 228, 228);
    }
  }
}
Code to advice notification:
  m_Sink.Advise(ptrCalendarConn, XTP_NC_CALENDAR_BEFORE_DRAW_THEMEOBJECT, &CCalendarDemoView::OnBeforeDrawThemeObject);

--
WBR,
Serge
Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.141 seconds.