|  | 
| Controlling Background Color of Events | 
| Post Reply   | 
| Author | |
| pdub   Newbie   Joined: 29 January 2008 Location: United States Status: Offline Points: 4 |  Post Options  Thanks(0)  Quote  Reply  Topic: Controlling Background Color of Events 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();  | |
|  | |
| pdub   Newbie   Joined: 29 January 2008 Location: United States Status: Offline Points: 4 |  Post Options  Thanks(0)  Quote  Reply  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(...)". | |
|  | |
| prashant   Senior Member     Joined: 19 February 2007 Location: India Status: Offline Points: 165 |  Post Options  Thanks(0)  Quote  Reply  Posted: 06 March 2008 at 7:52am | 
| 
   Can you please post the working source again? Thanks in advance. | |
|  | |
| pdub   Newbie   Joined: 29 January 2008 Location: United States Status: Offline Points: 4 |  Post Options  Thanks(0)  Quote  Reply  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 );        }     } } | |
|  | |
| prashant   Senior Member     Joined: 19 February 2007 Location: India Status: Offline Points: 165 |  Post Options  Thanks(0)  Quote  Reply  Posted: 06 March 2008 at 10:25am | 
| 
   Thanks a lot   I am looking for the same. | |
|  | |
| prashant   Senior Member     Joined: 19 February 2007 Location: India Status: Offline Points: 165 |  Post Options  Thanks(0)  Quote  Reply  Posted: 30 April 2008 at 2:31am | 
| 
   Hi, Is there any way to set Event text color? Thanks in advance. | |
|  | |
| pdub   Newbie   Joined: 29 January 2008 Location: United States Status: Offline Points: 4 |  Post Options  Thanks(0)  Quote  Reply  Posted: 01 May 2008 at 3:37pm | 
| 
   Concerning setting the Event Text Color, I was never able to get it to work.  
 Sorry. | |
|  | |
| 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 |