Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Calendar
  New Posts New Posts RSS Feed - Controlling Background Color of Events
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Controlling Background Color of Events

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


Joined: 29 January 2008
Location: United States
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote pdub Quote  Post ReplyReply Direct Link To This Post 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(); 
Back to Top
pdub View Drop Down
Newbie
Newbie


Joined: 29 January 2008
Location: United States
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote pdub Quote  Post ReplyReply Direct Link To This Post 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(...)".
 
   
Back to Top
prashant View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 February 2007
Location: India
Status: Offline
Points: 165
Post Options Post Options   Thanks (0) Thanks(0)   Quote prashant Quote  Post ReplyReply Direct Link To This Post Posted: 06 March 2008 at 7:52am
Can you please post the working source again?

Thanks in advance.
Back to Top
pdub View Drop Down
Newbie
Newbie


Joined: 29 January 2008
Location: United States
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote pdub Quote  Post ReplyReply Direct Link To This Post 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 );
       }
    }
}
Back to Top
prashant View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 February 2007
Location: India
Status: Offline
Points: 165
Post Options Post Options   Thanks (0) Thanks(0)   Quote prashant Quote  Post ReplyReply Direct Link To This Post Posted: 06 March 2008 at 10:25am
Thanks a lot
I am looking for the same.

Back to Top
prashant View Drop Down
Senior Member
Senior Member
Avatar

Joined: 19 February 2007
Location: India
Status: Offline
Points: 165
Post Options Post Options   Thanks (0) Thanks(0)   Quote prashant Quote  Post ReplyReply Direct Link To This Post Posted: 30 April 2008 at 2:31am
Hi,

Is there any way to set Event text color?
Thanks in advance.
Back to Top
pdub View Drop Down
Newbie
Newbie


Joined: 29 January 2008
Location: United States
Status: Offline
Points: 4
Post Options Post Options   Thanks (0) Thanks(0)   Quote pdub Quote  Post ReplyReply Direct Link To This Post Posted: 01 May 2008 at 3:37pm
Concerning setting the Event Text Color, I was never able to get it to work. 
 
Sorry.
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.125 seconds.