Print Page | Close Window

Event being drawn in BeforeDrawThemeObject

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=13663
Printed Date: 12 December 2024 at 9:57am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Event being drawn in BeforeDrawThemeObject
Posted By: wakerunner
Subject: Event being drawn in BeforeDrawThemeObject
Date Posted: 12 March 2009 at 9:40am
How can you determine the event that is currently being drawn in the "BeforeDrawThemeObject" event?


-------------
Product: Xtreme SuitePro (ActiveX) version 13.3.1
Platform: Windows 7 64 bit
Language: Visual Basic 6.0





Replies:
Posted By: mdoubson
Date Posted: 13 March 2009 at 10:17am
see https://forum.codejock.com/forum_posts.asp?TID=13652 - https://forum.codejock.com/forum_posts.asp?TID=13652

-------------
Mark Doubson, Ph.D.


Posted By: wakerunner
Date Posted: 13 March 2009 at 10:30am
That is my topic also.
 
I appreciate your help but I have not been able to convert your sample code to make it work in VB. I started this topic with the subject narrowed down to what I have not been able to get.
 


-------------
Product: Xtreme SuitePro (ActiveX) version 13.3.1
Platform: Windows 7 64 bit
Language: Visual Basic 6.0




Posted By: mdoubson
Date Posted: 13 March 2009 at 10:35am
Private Sub CalendarControl_BeforeDrawThemeObject(ByVal eObjType As XtremeCalendarControl.CalendarBeforeDrawThemeObject, ByVal Params As Variant)
    Dim pTheme2007 As CalendarThemeOffice2007
    Set pTheme2007 = CalendarControl.Theme
   
    If eObjType = xtpCalendarBeforeDraw_DayViewDay Then
        Debug.Print "BitmapID=" & pTheme2007.DayView.Day.Header.BackgroundNormal.BitmapID
        pTheme2007.DayView.Day.Header.BackgroundNormal.BitmapID = 0
    End If
   
    If eObjType = xtpCalendarBeforeDraw_MonthViewWeekDayHeader Then
        pTheme2007.MonthView.WeekDayHeader.BackgroundNormal.BitmapID = 0
    End If
   
    If eObjType = xtpCalendarBeforeDraw_MonthViewWeekHeader Then
        pTheme2007.MonthView.WeekHeader.BaseColor = RGB((Params + 1) * 11, (Params + 1) * (Params + 1) * 7 Mod 256, (Params + 1) * 311 Mod 256)
        pTheme2007.MonthView.WeekHeader.BackgroundNormal.BitmapID = 0
    End If
   
    If eObjType = xtpCalendarBeforeDraw_DayViewTimeScale Then
        If Params = 2 Then
            pTheme2007.DayView.TimeScale.TimeTextBigBase.Color = RGB(200, 0, 0)
            pTheme2007.DayView.TimeScale.TimeTextSmall.Color = RGB(0, 170, 0)
            pTheme2007.DayView.TimeScale.BackgroundColor = RGB(170, 170, 55)
        End If
    ElseIf eObjType = xtpCalendarBeforeDraw_DayViewTimeScaleCell Then
        'CalendarControl.Theme.DayView.TimeScale.TimeTextBigBase.Font.Strikethrough = (Second(Now) Mod 2) = 0
        Dim nSubCellIndex
        nSubCellIndex = Params.Minutes / CalendarControl.DayView.TimeScale
       
        If Params.Minutes = -1 Then
            pTheme2007.DayView.TimeScale.TimeTextBigBase.Font.Bold = (Params.Index Mod 2) = 0
            pTheme2007.DayView.TimeScale.TimeTextSmall.Font.Bold = (Params.Index Mod 2) = 0
            pTheme2007.DayView.TimeScale.TimeTextSmall.Color = 20000 + 1111 * Params.Index
        Else
            If (nSubCellIndex Mod 2) = 0 And CalendarControl.DayView.TimeScale < 15 Then
                pTheme2007.DayView.TimeScale.ShowMinutes = False
            Else
                pTheme2007.DayView.TimeScale.TimeTextBigBase.Font.Bold = nSubCellIndex Mod 4 = 0
                pTheme2007.DayView.TimeScale.TimeTextBigBase.Color = _
                    RGB(33 * nSubCellIndex Mod 200, _
                        77 * Params.Minutes Mod 55, _
                        17 * Params.Minutes Mod 155)
                               
                pTheme2007.DayView.TimeScale.AmPmText.Color = RGB(255, 255, 255)
                pTheme2007.DayView.TimeScale.AmPmText.Font.Bold = True
               
               
                pTheme2007.DayView.TimeScale.TimeTextSmall.Font.Bold = False
                pTheme2007.DayView.TimeScale.TimeTextSmall.Color = 20000 + 111 * Params.Index
               
            End If
       
        End If
       
        If CalendarControl.DayView.TimeScale > 15 Then
            CalendarControl.Theme.DayView.TimeScale.TimeTextBigBase.Color = 20000 + 100 * Params.Index
        End If
        CalendarControl.Theme.DayView.TimeScale.LineColor = CalendarControl.Theme.DayView.TimeScale.TimeTextBigBase.Color
       
    ElseIf eObjType = xtpCalendarBeforeDraw_DayViewTimeScaleCaption Then
        CalendarControl.Theme.DayView.TimeScale.Caption.Font.Italic = (Second(Now) Mod 2) = 0
        CalendarControl.Theme.DayView.TimeScale.Caption.Color = RGB(10, 200, 100)
        CalendarControl.Theme.DayView.TimeScale.LineColor = RGB(10, 200, 100)
       
    ElseIf eObjType = xtpCalendarBeforeDraw_DayViewCell Then
        Dim pCell As CalendarThemeDayViewCellParams
        Set pCell = Params
       
        If pCell.Index Mod 3 = 0 Then
            If pCell.WorkCell Then
                pTheme2007.DayView.Day.Group.Cell.WorkCell.BackgroundColor = RGB(200, 255, 0)
            Else
                pTheme2007.DayView.Day.Group.Cell.NonWorkCell.BackgroundColor = RGB(255, 200, 0)
            End If
        End If
       
    ElseIf eObjType = xtpCalendarBeforeDraw_DayViewDay Then
        pTheme2007.DayView.Day.Header.BaseColor = 20000 + 100 * Weekday(Params.Date)
        pTheme2007.DayView.Day.Header.TodayBaseColor = RGB(0, 0, 0)
   
    ElseIf eObjType = xtpCalendarBeforeDraw_MonthViewDay Then
        pTheme2007.MonthView.Day.Header.BaseColor = RGB(Day(Params.Date) * 11 Mod 255, Day(Params.Date) * 257 Mod 255, Day(Params.Date) * 1001 Mod 255)
        pTheme2007.MonthView.Day.Header.TodayBaseColor = RGB(255, 0, 0)
        pTheme2007.MonthView.Day.TodayBorderColor = pTheme2007.MonthView.Day.Header.TodayBaseColor
   
    ElseIf eObjType = xtpCalendarBeforeDraw_MonthViewWeekDayHeader Then
       
        If Params >= 0 Then
            pTheme2007.MonthView.WeekDayHeader.BaseColor = _
                RGB(Params * 55 Mod 155 + 100, _
                    Params * 7 Mod 55 + 200, _
                    Params * 101 Mod 200 + 55)
        End If
       
    End If
   
End Sub


-------------
Mark Doubson, Ph.D.


Posted By: wakerunner
Date Posted: 13 March 2009 at 10:42am
This is the code from the sample program, I have that. Unless I am missing something there is no place in that code that tells me the "topicID" of the event or any other refernece to the specific event, only references to details about the graphical characteristics of the object being drawn.
 
Maybe I am trying to do something in the wrong place. What i am trying to do is have the Subject drawn with a strikeout font when a custom xml property of the event "completed" = true.


-------------
Product: Xtreme SuitePro (ActiveX) version 13.3.1
Platform: Windows 7 64 bit
Language: Visual Basic 6.0




Posted By: mdoubson
Date Posted: 13 March 2009 at 11:03am
in C++ OnBeforeDrawThemeObject(XTP_NOTIFY_CODE Event, WPARAM wParam , LPARAM lParam)

Event can be XTP_NC_CALENDAR_BEFORE_DRAW_THEMEOBJECT

wParam can be xtpCalendarBeforeDraw_DayViewEvent
lParam can be CXTPCalendarDayViewEvent* pViewEvent = (CXTPCalendarDayViewEvent*)lParam;
from here you can get event as pViewEvent->GetEvent()
now you can get event properties e.g. GetSubject() and so on.
In ActiveX code there are enum:
 typedef  [ uuid(ECEC1B12-DD2C-47ab-8F12-9A813A074FAA), helpcontext(4493) ]
 enum
 {
  [helpcontext(4493)] xtpCalendarBeforeDraw_DayViewTimeScale   = 0x00000001, // Params - (long) nTimeScale = {1 - main, 2 - additional}
  [helpcontext(4493)] xtpCalendarBeforeDraw_DayViewTimeScaleCaption = 0x00000002, // Params - (long) nTimeScale = {1 - main, 2 - additional};
  [helpcontext(4493)] xtpCalendarBeforeDraw_DayViewTimeScaleCell  = 0x00000004, // Params - (Dispatch) CalendarThemeDayViewTimeScaleCellParams*
  [helpcontext(4493)] xtpCalendarBeforeDraw_DayViewDay    = 0x00000010, // Params - (Dispatch) CalendarViewDay*;
  [helpcontext(4493)] xtpCalendarBeforeDraw_DayViewDayGroup   = 0x00000020, // Params - (Dispatch) CalendarViewGroup*;
  [helpcontext(4493)] xtpCalendarBeforeDraw_DayViewCell    = 0x00000040, // Params - (Dispatch) CalendarThemeDayViewCellParams*;
  [helpcontext(4493)] xtpCalendarBeforeDraw_DayViewEvent    = 0x00000080, // Params - (Dispatch) CalendarViewEvent*;
  [helpcontext(4493)] xtpCalendarBeforeDraw_MonthViewDay    = 0x00001000, // Params - (Dispatch) CalendarViewDay*
  [helpcontext(4493)] xtpCalendarBeforeDraw_MonthViewEvent   = 0x00002000, // Params - (Dispatch) CalendarViewEvent*
  [helpcontext(4493)] xtpCalendarBeforeDraw_MonthViewWeekDayHeader = 0x00004000, // Params - (long) WeekDay = {1-Sun, 2-Mon, ...}, -1 for common part;
  [helpcontext(4493)] xtpCalendarBeforeDraw_MonthViewWeekHeader  = 0x00008000, // Params - (long) WeekIndex={0...N}, -1 for common part;
  [helpcontext(4493)] xtpCalendarBeforeDraw_WeekViewDay    = 0x00100000, // Params - (Dispatch) CalendarViewDay* 
  [helpcontext(4493)] xtpCalendarBeforeDraw_WeekViewEvent    = 0x00200000, // Params - (Dispatch) CalendarViewEvent*
 } CalendarBeforeDrawThemeObject;
also  typedef   [ uuid(C9D2A6AD-CFFA-49ec-9DE4-24738B9F1E72), helpcontext(4509) ]
 enum
 {
  [helpcontext(4509)] xtpCalendarItemText_EventSubject   = 0x00000001,
  [helpcontext(4509)] xtpCalendarItemText_EventLocation   = 0x00000002,
  [helpcontext(4509)] xtpCalendarItemText_DayViewDayHeader  = 0x00000004,
  [helpcontext(4509)] xtpCalendarItemText_WeekViewDayHeader  = 0x00000008,
  [helpcontext(4509)] xtpCalendarItemText_MonthViewDayHeader  = 0x00000010,
  [helpcontext(4509)] xtpCalendarItemText_MonthViewWeekDayHeader = 0x00000020,
  
  [helpcontext(4509)] xtpCalendarItemText_EventToolTipText  = 0x00000040,
 
  [helpcontext(4509)] xtpCalendarItemText_EventStartTimeText  = 0x00000100,
  [helpcontext(4509)] xtpCalendarItemText_EventEndTimeText  = 0x00000200,
 
 } XTPCalendarGetItemText;
 
   [id(25), propget, helpcontext(4507)] CalendarFlagsSet* AskItemTextFlags();
   [id(26), propget, helpcontext(4522)] CalendarFlagsSet* BeforeDrawThemeObjectFlags();
 
and finally function void CCalendarControlCtrl::OnEvent_BeforeDrawThemeObject(XTP_NOTIFY_CODE Event, WPARAM dwParam1, LPARAM dwParam2)
{
 ASSERT(XTP_NC_CALENDAR_BEFORE_DRAW_THEMEOBJECT == Event);
 
 if (XTP_NC_CALENDAR_BEFORE_DRAW_THEMEOBJECT != Event)
 {  
  return;
 }
  
 int nObjType = (XTPCalendarBeforeDrawThemeObject)dwParam1;
 COleVariant varParams;
 varParams.vt = VT_EMPTY;
 CCmdTarget* pObject = NULL;
 switch (nObjType)
 {
 case xtpCalendarBeforeDraw_DayViewTimeScale:
 case xtpCalendarBeforeDraw_DayViewTimeScaleCaption:
 case xtpCalendarBeforeDraw_MonthViewWeekDayHeader:
 case xtpCalendarBeforeDraw_MonthViewWeekHeader:
  varParams = (long)dwParam2;
  break;
 case xtpCalendarBeforeDraw_DayViewTimeScaleCell:  
  if (!m_pThemeDVTSCellParamsHolder)
  {
   m_pThemeDVTSCellParamsHolder = new CCalendarThemeDayViewTimeScaleCellParams_imp();
   if (!m_pThemeDVTSCellParamsHolder)
    return;
  }  
  ASSERT(dwParam2);
  m_pThemeDVTSCellParamsHolder->SetDataRef((XTP_CALENDAR_THEME_DAYVIEWTIMESCALECELL_PARAMS*)dwParam2);
  pObject = m_pThemeDVTSCellParamsHolder;
  
  break;
 case xtpCalendarBeforeDraw_DayViewDay:  // dwParam2 - [in] pDayViewDay;  
  ASSERT(dwParam2);
  pObject = (CCmdTarget*)(CXTPCalendarDayViewDay*)dwParam2;   
  break;
 
 case xtpCalendarBeforeDraw_DayViewDayGroup: // dwParam2 - [in] pDayViewGroup;
  ASSERT(dwParam2);
  pObject = (CCmdTarget*)(CXTPCalendarDayViewGroup*)dwParam2;
  break;
 case xtpCalendarBeforeDraw_DayViewCell:  // dwParam2 - [in] XTP_CALENDAR_THEME_DAYVIEWCELL_PARAMS *;
  if (!m_pThemeDVCellParamsHolder)
  {
   m_pThemeDVCellParamsHolder = new CCalendarThemeDayViewCellParams_imp();
   if (!m_pThemeDVCellParamsHolder)
    return;
  }  
  ASSERT(dwParam2);
  m_pThemeDVCellParamsHolder->SetDataRef((XTP_CALENDAR_THEME_DAYVIEWCELL_PARAMS*)dwParam2);
  pObject = m_pThemeDVCellParamsHolder;
  break;
 case xtpCalendarBeforeDraw_DayViewEvent: // dwParam2 - [in] pDayViewEvent;
  ASSERT(dwParam2);
  pObject = (CCmdTarget*)(CXTPCalendarDayViewEvent*)dwParam2;
  break;
 //=======================================================================
 case xtpCalendarBeforeDraw_MonthViewDay:  // dwParam2 - [in] pMonthViewDay;
  ASSERT(dwParam2);
  pObject = (CCmdTarget*)(CXTPCalendarMonthViewDay*)dwParam2;
  break;
 case xtpCalendarBeforeDraw_MonthViewEvent:  // dwParam2 - [in] pMonthViewEvent;
  ASSERT(dwParam2);
  pObject = (CCmdTarget*)(CXTPCalendarMonthViewEvent*)dwParam2;
  break;
 //=======================================================================
 case xtpCalendarBeforeDraw_WeekViewDay:  // dwParam2 - [in] pWeekViewDay;
  ASSERT(dwParam2);
  pObject = (CCmdTarget*)(CXTPCalendarWeekViewDay*)dwParam2;
  break;
 case xtpCalendarBeforeDraw_WeekViewEvent:  // dwParam2 - [in] pWeekViewEvent;
  ASSERT(dwParam2);
  pObject = (CCmdTarget*)(CXTPCalendarWeekViewEvent*)dwParam2;
  break;
 default:
  ASSERT(FALSE);
  return;
 }
 //------------------------------------------------
 if (pObject)
 {
  varParams.vt = VT_DISPATCH;
  varParams.pdispVal = pObject->GetIDispatch(TRUE);
 }
 //================================================
 FireBeforeDrawThemeObject(nObjType, &varParams);
 //================================================
 if (m_pThemeDVTSCellParamsHolder)
  m_pThemeDVTSCellParamsHolder->SetDataRef(NULL);
 if (m_pThemeDVCellParamsHolder)
  m_pThemeDVCellParamsHolder->SetDataRef(NULL);
}

It should help you to analyze passed params


-------------
Mark Doubson, Ph.D.


Posted By: wakerunner
Date Posted: 13 March 2009 at 12:02pm
I'm sorry but you might as well be speaking in Chinese, none of that means anything to me and it doesn't work in VB.
 
Is there a support tech that knows VB?


-------------
Product: Xtreme SuitePro (ActiveX) version 13.3.1
Platform: Windows 7 64 bit
Language: Visual Basic 6.0




Posted By: mdoubson
Date Posted: 13 March 2009 at 1:11pm
Private Sub CalendarControl_BeforeDrawThemeObject(ByVal eObjType As XtremeCalendarControl.CalendarBeforeDrawThemeObject, ByVal Params As Variant)
    Dim pTheme2007 As CalendarThemeOffice2007
    Set pTheme2007 = CalendarControl.Theme
    
    
    If eObjType = xtpCalendarBeforeDraw_DayViewDay Then
        Debug.Print "BitmapID=" & pTheme2007.DayView.Day.Header.BackgroundNormal.BitmapID
        pTheme2007.DayView.Day.Header.BackgroundNormal.BitmapID = 0
       
        'pTheme2007.DayView.Day.Group.SingleDayEvent.Normal.Body.Font.Strikethrough = True
        pTheme2007.DayView.Day.Group.SingleDayEvent.Normal.Subject.Font.Strikethrough = True
       
    End If
.........
 see snapshot https://forum.codejock.com/uploads/temp/20090313_131214_ScreenShot3.jpg - https://forum.codejock.com/uploads/temp/20090313_131214_ScreenShot3.jpg
 
 


-------------
Mark Doubson, Ph.D.


Posted By: SuperMario
Date Posted: 13 March 2009 at 1:39pm
Originally posted by wakerunner wakerunner wrote:

How can you determine the event that is currently being drawn in the "BeforeDrawThemeObject" event?


Pretty simple:

Set this in form load:
CalendarControl.BeforeDrawThemeObjectFlags = -1 ' set all

Then:

Private Sub CalendarControl_BeforeDrawThemeObject(ByVal eObjType As XtremeCalendarControl.CalendarBeforeDrawThemeObject, ByVal Params As Variant)
  
    Dim pEvent As CalendarEvent
       
    If eObjType = xtpCalendarBeforeDraw_DayViewEvent Then
        Set pEvent = Params.Event
        Debug.Print "EventID = " & pEvent.Id & ". Subject = " & pEvent.Subject
    End If

End Sub


Posted By: wakerunner
Date Posted: 13 March 2009 at 1:47pm
I know that part. I don't think you under stand what I am trying to do. That code will make all subjects fontstrikethrough. I only want certain events to be strikethrough, like below:
 
 
Private Sub CalendarControl_BeforeDrawThemeObject(ByVal eObjType As XtremeCalendarControl.CalendarBeforeDrawThemeObject, ByVal Params As Variant)
Dim pEvent As CalendarEvent
If eObjType = xtpCalendarBeforeDraw_DayViewEvent Then
     if pEvent.CustomProperties.Property("status") = "completed" then
     pTheme2007.DayView.Day.Group.SingleDayEvent.Normal.Subject.Font.Strikethrough = True
     end if
end if
End Sub 
 
The question is how do I determine which CalendarEvent is being drawn each firing of the "BeforeDrawThemeObject"? How do I find or set the pEvent?
 
 


-------------
Product: Xtreme SuitePro (ActiveX) version 13.3.1
Platform: Windows 7 64 bit
Language: Visual Basic 6.0




Posted By: SuperMario
Date Posted: 13 March 2009 at 1:53pm
I showed you if you look at my code.  use my code and mark's and you have solution.

Private Sub CalendarControl_BeforeDrawThemeObject(ByVal eObjType As XtremeCalendarControl.CalendarBeforeDrawThemeObject, ByVal Params As Variant)

Dim pEvent As CalendarEvent

If eObjType = xtpCalendarBeforeDraw_DayViewEvent Then
Set pEvent = Params.Event

     if pEvent.CustomProperties.Property("status") = "completed" then

     pTheme2007.DayView.Day.Group.SingleDayEvent.Normal.Subject.Font.Strikethrough = True
     end if

end if

End Sub



Posted By: wakerunner
Date Posted: 13 March 2009 at 1:55pm
I'm sorry I made that last post before I saw your post. That looks like what I am looking for.
 
I knew it would be something really easy I was missing. It works perfect, thanks for the help!
 


-------------
Product: Xtreme SuitePro (ActiveX) version 13.3.1
Platform: Windows 7 64 bit
Language: Visual Basic 6.0




Posted By: BCS123
Date Posted: 27 July 2012 at 6:07pm
I have a similar issue....  how do I get the strike through  to apply only for those events that are in dark purple only (the ones circled in red shud be regular text). Would also like to change the font color to whiteInsert Hyperlink for the strike thro events .. thx


Posted By: SuperMario
Date Posted: 20 August 2012 at 9:19am
This code will change color of event if the word "Deleted" is int he subject.  You can modify it to do as you with and check for label:
Private Sub CalendarControl_BeforeDrawThemeObject(ByVal eObjType As XtremeCalendarControl.CalendarBeforeDrawThemeObject, ByVal DrawParams As Variant)
On Error Resume Next:
Dim pCell As CalendarThemeDayViewCellParams

Dim pTheme2007 As CalendarThemeOffice2007
Set pTheme2007 = CalendarControl.Theme

Dim pEvent As CalendarEvent
Set pEvent = Nothing

If eObjType = xtpCalendarBeforeDraw_DayViewEvent Then
Set pEvent = DrawParams.Event

If InStr(pEvent.Subject, "DELETED") > 0 Then
pEvent.Label = 1
End If

End If
End Sub



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