Print Page | Close Window

Cell Color in Month View

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Calendar
Forum Description: Topics Related to Codejock Calendar
URL: http://forum.codejock.com/forum_posts.asp?TID=6009
Printed Date: 04 May 2024 at 10:51am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Cell Color in Month View
Posted By: smis
Subject: Cell Color in Month View
Date 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.
 
 
 



Replies:
Posted By: sserge
Date 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



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net