Print Page | Close Window

Controlling Background Color of Events

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=9445
Printed Date: 25 June 2024 at 3:01am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Controlling Background Color of Events
Posted By: pdub
Subject: Controlling Background Color of Events
Date Posted: 30 January 2008 at 8:53am

I am trying to set the background color of an event in the calendar to a custom color.  I am not using the 2007 theme.  From the documentation, it appears that I could create new custom Calendar Label Event, and assign that event's Label Id to a Calendar Event. 

I tried this but it doesn't work.  I suspect the calendar does not know about my new custom Label Event.
 
Where is what I have tried.  How can I get my custom background color to work?
 
 
// First I declare a Calendar Events Label object.
CXTPCalenarEventLabels  _calendarEventLabels;
 
// I initialize the calendar events label object to get the defaul labels
_calendarEventLabels.InitDefaultValues();
 
// I create a new label event
CXTPCalendarEventLabel * eventLabel = new CXTPCalendarEventLabel( newLabelID, newBackgroundColor, newLabelName  );
 
// I add the new label event to the calendar events label object
_calendarEventLabels.Add( eventLabel );
 
// I create a calendar event
CXTPCalendarEventPtr calendarEvent = newCalendarEvent(...);
 
// I assign the new label id to calendar event
calendarEvent->SetLabelID( newLabelID );
 
// I add my event to my data provider
calendarData->AddEvent( calendarEvent );
 
// I call populate
Populate(); 



Replies:
Posted By: pdub
Date Posted: 05 February 2008 at 11:39am
To answer my own question:
 
The CXTPCalendarData class provides an interface to define custom event labels called "SetLabelList(...)".
 
   


Posted By: prashant
Date Posted: 06 March 2008 at 7:52am
Can you please post the working source again?

Thanks in advance.


Posted By: pdub
Date Posted: 06 March 2008 at 9:06am
Hopefully, this is what you are looking for.
 
I have a class called CWin32Calendar.  The class inherits from CXTPCalendarControl.  In the class, I keep a copy of the labels
CXTPCalendarEventLabels _calendarEventLabels;
 
In the class constructor, I initialize _calendarEventLabels with the default labels by calling InitDefaultValues()
_calendarEventLabels.InitDefaultValues();
 
Later on, I add my own custom event labels to _calendarEventLabels.
 
For the calendar to know about my custom labels, I must update the event labels via the calendar's data provider.  Here is the code I am using to update the data provider.
 
void CWin32Calendar::setCustomCalendarEventLabels()
{
    // Are we using custom labels?
    if ( _customEventLabels )
    {
        // Yes
        // Now, get the data provider, make a copy of our label list
        // and set the data providers label list, so the data provider
        // knows about the custom labels.
        CXTPCalendarData * calendarData = GetDataProvider();
        if ( calendarData )
       {
           // We are going to make a copy of our local list of event labels
           CXTPCalendarEventLabels * copyCalendarEventLabels
                                              = new CXTPCalendarEventLabels();
           if ( copyCalendarEventLabels )
           {
               // Go through our local copy of the labels,
               // and make a copy
               int labelCount = _calendarEventLabels.GetCount();
               for ( int i=0; i < labelCount; i++ )
               {
                   CXTPCalendarEventLabel * eventLabel = 
                            _calendarEventLabels.Find( i );
                   if ( eventLabel )
                   {
                       // Copy label
                      CXTPCalendarEventLabel * copyEventLabel = new
                          CXTPCalendarEventLabel( eventLabel->m_nLabelID,
                                                           eventLabel->m_clrColor,
                                                           eventLabel->m_strName );
                       if ( copyEventLabel )
                       {
                           // Add the event lable copy to the event label list.
                           copyCalendarEventLabels->InsertAt( i,
                                                                      copyEventLabel );
                       }
                       else
                       {
                           ASSERT( FALSE );
                       }
                   }
                   else
                   {
                       ASSERT( FALSE );
                   }
               }
 
               // Update the data provider with the event label copy
               calendarData->SetLabelList( copyCalendarEventLabels );
           }
       }
       else
       {
           ASSERT( FALSE );
       }
    }
}


Posted By: prashant
Date Posted: 06 March 2008 at 10:25am
Thanks a lot
I am looking for the same.



Posted By: prashant
Date Posted: 30 April 2008 at 2:31am
Hi,

Is there any way to set Event text color?
Thanks in advance.


Posted By: pdub
Date Posted: 01 May 2008 at 3:37pm
Concerning setting the Event Text Color, I was never able to get it to work. 
 
Sorry.



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