Color-Coding With Office 2007 Theme |
Post Reply |
Author | |
jgordon428
Groupie Joined: 11 June 2009 Status: Offline Points: 21 |
Post Options
Thanks(0)
Posted: 18 October 2010 at 2:48pm |
We want to implement color coding of the calendar control in order to be able to show certain times as unavailable. I noticed that this seems doable with the office 2003 theme, but judging from what we've tried and the demo application, this doesn't work with the office 2007 theme. Any way around this with the 2007 theme?
|
|
Xander75
Senior Member Joined: 26 April 2007 Status: Offline Points: 353 |
Post Options
Thanks(0)
|
Hi jgordon428,
By colour coding the Calendar Control to show certain times as unavailable I believe you mean changing the Calendar cell colours, can you confirm if this is the case? If so I have done this for displaying the current working week schedule times using the following code in the BeforeDrawThemeObject event:
If you look specifically at the light yellow cell background colour, this is the colour defined as RGB(255, 255, 200) in the code above. As you can see we finish at 1pm on a Friday!!! Also please note that the "AppData.TimeStartMon" and other "AppData" variables are my own variables to store the date and time for the working day on screen. Just in case you go looking for these! lol |
|
Product: Xtreme SuitePro (ActiveX) v15.3.1
Platform: Windows 7 64-bit (SP1) Professional Edition Languages: C#.Net using Visual Studio 2012 & Visual Basic 6.0 (SP6) |
|
jgordon428
Groupie Joined: 11 June 2009 Status: Offline Points: 21 |
Post Options
Thanks(0)
|
Thank you so much for your reply, yes, this is exactly what I am looking for. However, one small issue... CalendarControl_BeforeDrawThemeObject is never called. I set a breakpoint there and it is never hit. Something I am missing?
Also, this all seems to be based on the "WorkCell". Does this relate to the properties CalendarControl.Options.WorkDayStartTime and WorkDayEndTime for determining what is a workcell vs nonworkcell? Or is this something different? I noticed for instance that I can set the workday start and end times and it will color code the schedule in a certain way. However, I could not find an option to set this per day, only a single global setting. Looks like your solution would solve this problem. Just not sure if I need to additionally set other properties about what is and is not a workcell. Thanks again.
|
|
dentor
Senior Member Joined: 30 November 2005 Location: France Status: Offline Points: 102 |
Post Options
Thanks(0)
|
Hello jgordon428,
To get the Event BeforeDrawThemeObject to be called, you must set the BeforeDrawThemeObjectFlags property to -1:
CalendarControl.BeforeDrawThemeObjectFlags = -1
|
|
Product: Xtreme SuitePro (ActiveX) version 13.0.0
Platform: Windows XP (32bit) - SP 3 Language: Visual Basic 6.0 SP 6 |
|
jgordon428
Groupie Joined: 11 June 2009 Status: Offline Points: 21 |
Post Options
Thanks(0)
|
Very helpful, thank you! I'm getting closer, but still not quite there...
I get a type mismatch error on Set pCell = DrawParams in Xander's example above. Also, I see the event CalendarControl_BeforeDrawDayViewCell which I think might be another event I can use for the color coding, but again I can't get it to fire. I looked for a property BeforeDrawDayViewCellFlags , but couldn't find one. I'm using version 13.4.0 of the activeX calendar control. Thanks for your help!
|
|
jgordon428
Groupie Joined: 11 June 2009 Status: Offline Points: 21 |
Post Options
Thanks(0)
|
After a bit of tweaking, I got everything to compile/run, but for some reason it's just coding every day as yellow from 8am-5pm and blue outside that time. Here's what I have so far. Is it something obvious I'm missing? I basically took your code and just made an array to store the start/stop times for each day. I suppose I don't understand the basic concept. Why is pTheme2007.DayView.Day.Group.Cell.WorkCell the object we want to set the background color of, and not pCell?
|
|
jgordon428
Groupie Joined: 11 June 2009 Status: Offline Points: 21 |
Post Options
Thanks(0)
|
Well, this seemed to solve it:
CalendarControl.Options.WorkDayStartTime = #12:00:00 AM# CalendarControl.Options.WorkDayEndTime = #11:59:59 PM# I guess the default values of 8-5 were overriding the custom theme colors. Everything is working now. Thanks to both of you for your help.
|
|
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 |