Página 1 de 1

Codejock Calendar Control and Active X

Publicado: Vie Mar 28, 2008 12:12 am
por Nick Hilder
Hi Jose
I have been having some fun with the Outlook style calendar control from
Code Jock.
I have a form with a calendar on it, I am able to set various things like,
time increments etc. I can capture events, haven't tried all, but I have at
least 10 so that looks promising.
I'm not really sure how to ask this question but here goes
The Calendar Class has a method called SetTheme()
Leaving Activex and OLE out for a sec this is how you use it
oTheme := CalendarThemeOffice2007():New(Self)
::oCalendar:SetTheme(oTheme)
Now, lets bring ActiveX / OLE back into it.
In Xailer I don;t have a class called CalendarThemeOffice2007 so I can't do
what I did above.
In an early bound OLE enviroment this class is imported via the type lib. So
then you can just use it.
What happens in the late bound world.
::oCalendar has no method to create the theme object, I can't get to it from
other objects either.
To create an appointment in the calendar you have to create an "event"
object, I can do this because I can get to a method via
::oCalendar:DataProvider:CreateEvent()
Using OLE Viewer and the Type Libs tree I was able to see that
CalendarThemeOffice2007 is a "coclass". The Calendar Control itself is a
coclass as well.
Is what I want to do possible or have a hit a limitation of late bound OLE?
Maybe I can use TOLEAuto() and it's guid to get a copy of the object?
Regards Nick
My source code is below. You need to import this
"Codejock.CalendarControl.11.2.2"
/*
* Project: timesheet
* File: Form1.prg
* Description:
* Author:
* Date: 03-26-2008
*/
#include "Xailer.ch"
#include "CalendarControl.ch"
CLASS TForm1 FROM TForm
COMPONENT oCalendar
COMPONENT oPanel1
COMPONENT oListbox1
COMPONENT oLabel1
METHOD CreateForm()
METHOD LoadCalendar( oSender )
METHOD EventChanged( )
METHOD OnDblClick( ) //DblClick
in Xtreme Calendar ActiveX Control v11.2
METHOD ContextMenu( oSender, x, y)
METHOD EventDeleted( )
METHOD OnLButtonDown( oSender, nButton, nShift , x, y )
//MouseDown in Xtreme Calendar ActiveX Control v11.2
METHOD OnKeyDown( oSender, nKeyCode, nShift ) //KeyDown
in Xtreme Calendar ActiveX Control v11.2
METHOD EventAdded()
ENDCLASS
#include "Form1.xfm"
//---------------------------------------------------------- --------------------
METHOD LoadCalendar( oSender ) CLASS TForm1
Local oDataProvider, oEvent, oActiveView, oTheme
WITH OBJECT ::oCalendar := TCalendarControl():New(::oPanel1)
:nAlign := alClient
:EventChangedEx := "EventChanged"
:ContextMenu := "ContextMenu"
:EventDeletedEx := "EventDeleted"
:OnKeyDown := "OnKeyDown"
:EventAddedEx := "EventAdded"
:OnLButtonDown := "OnLButtonDown"
:OnDblClick := "OnDblClick"
:Create()
END
::oCalendar:viewtype := xtpCalendarDayView
oActiveView := ::oCalendar:ActiveView()
oActiveView:TimeScale(6)
//THis is where we set the theme
//oTheme := ::oCalendar:??
//::oCalendar:SetTheme(oTheme)
::oCalendar:SetDataProvider("Provider=custom")
::oCalendar:DataProvider:Create()
::oCalendar:DataProvider:Open()
oEvent := ::oCalendar:DataProvider:CreateEvent()
oEvent:StartTime := DateTime()
oEvent:EndTime := DateTime() + .1
oEvent:Subject := "6972: STEBRI - Install ADS"
oEvent:Label := 1
::oCalendar:DataProvider:AddEvent(oEvent)
::oCalendar:Populate()
::oCalendar:DayView:ScrollToWorkDayBegin()
RETURN Nil
//---------------------------------------------------------- --------------------
METHOD EventChanged( oSender ) CLASS TForm1
::oListBox1:AddItem("An Event/Appointment was edited")
::oListBox1:nIndex := Len(::oListBox1:aItems)
Return Self
//---------------------------------------------------------- --------------------
METHOD OnDblClick( oSender ) CLASS TForm1
::oListBox1:AddItem("The Calendar was double clicked")
::oListBox1:nIndex := Len(::oListBox1:aItems)
Return Self
//---------------------------------------------------------- --------------------
METHOD ContextMenu( oSender, x, y ) CLASS TForm1
::oListBox1:AddItem("The user requested the context menu, it should
appear at X: " + AllTrim(Str(x)) + " Y: " + AllTrim(Str(y)) )
::oListBox1:nIndex := Len(::oListBox1:aItems)
Return Self
METHOD EventDeleted( oSender ) CLASS TForm1
::oListBox1:AddItem("An Event/Appointment was deleted")
::oListBox1:nIndex := Len(::oListBox1:aItems)
Return Self
METHOD OnLButtonDown( oSender, nButton, nShift , x, y ) CLASS TForm1
::oListBox1:AddItem("The mouse was clicked, the button was: " +
AllTrim(Str(nButton)) + " Shift Value: " + AllTrim(Str(nShift)) + " X: " +
AllTrim(Str(x)) + " Y: " + AllTrim(Str(y)))
::oListBox1:nIndex := Len(::oListBox1:aItems)
Return Self
METHOD OnKeyDown( oSender, nKeyCode, nShift ) CLASS TForm1
::oListBox1:AddItem("A key on the keyboard was pressed: ASCII " +
AllTrim(Str(nKeyCode)) + " Shift Value: " + AllTrim(Str(nShift)) )
::oListBox1:nIndex := Len(::oListBox1:aItems)
Return Self
METHOD EventAdded( oSender ) CLASS TForm1
::oListBox1:AddItem("An Event/Appointment was added")
::oListBox1:nIndex := Len(::oListBox1:aItems)
Return Self
//---------------------------------------------------------- --------------------

Codejock Calendar Control and Active X

Publicado: Vie Mar 28, 2008 12:52 am
por Nick Hilder
Sorry, wrong group
"Nick Hilder" <nick_Nospam#$%@capsol.com%NOSPAM%.au> wrote in message
news:[email=47ec29ff@ozsrv2.ozlan.local...]47ec29ff@ozsrv2.ozlan.local...[/email]
> Hi Jose
>
> I have been having some fun with the Outlook style calendar control from
> Code Jock.
>
> I have a form with a calendar on it, I am able to set various things like,
> time increments etc. I can capture events, haven't tried all, but I have
> at least 10 so that looks promising.
>
> I'm not really sure how to ask this question but here goes
>
> The Calendar Class has a method called SetTheme()
>
> Leaving Activex and OLE out for a sec this is how you use it
>
> oTheme := CalendarThemeOffice2007():New(Self)
>
> ::oCalendar:SetTheme(oTheme)
>
> Now, lets bring ActiveX / OLE back into it.
>
> In Xailer I don;t have a class called CalendarThemeOffice2007 so I can't
> do what I did above.
>
> In an early bound OLE enviroment this class is imported via the type lib.
> So then you can just use it.
>
> What happens in the late bound world.
>
> ::oCalendar has no method to create the theme object, I can't get to it
> from other objects either.
>
> To create an appointment in the calendar you have to create an "event"
> object, I can do this because I can get to a method via
> ::oCalendar:DataProvider:CreateEvent()
>
> Using OLE Viewer and the Type Libs tree I was able to see that
> CalendarThemeOffice2007 is a "coclass". The Calendar Control itself is a
> coclass as well.
>
> Is what I want to do possible or have a hit a limitation of late bound
> OLE?
>
> Maybe I can use TOLEAuto() and it's guid to get a copy of the object?
>
> Regards Nick
>
> My source code is below. You need to import this
> "Codejock.CalendarControl.11.2.2"
>
> /*
> * Project: timesheet
> * File: Form1.prg
> * Description:
> * Author:
> * Date: 03-26-2008
> */
>
> #include "Xailer.ch"
> #include "CalendarControl.ch"
> CLASS TForm1 FROM TForm
> COMPONENT oCalendar
> COMPONENT oPanel1
> COMPONENT oListbox1
> COMPONENT oLabel1
> METHOD CreateForm()
> METHOD LoadCalendar( oSender )
> METHOD EventChanged( )
> METHOD OnDblClick( )
> //DblClick in Xtreme Calendar ActiveX Control v11.2
> METHOD ContextMenu( oSender, x, y)
> METHOD EventDeleted( )
> METHOD OnLButtonDown( oSender, nButton, nShift , x, y ) //MouseDown in
> Xtreme Calendar ActiveX Control v11.2
> METHOD OnKeyDown( oSender, nKeyCode, nShift ) //KeyDown
> in Xtreme Calendar ActiveX Control v11.2
> METHOD EventAdded()
>
>
> ENDCLASS
>
> #include "Form1.xfm"
>
> //---------------------------------------------------------- --------------------
>
> METHOD LoadCalendar( oSender ) CLASS TForm1
>
> Local oDataProvider, oEvent, oActiveView, oTheme
> WITH OBJECT ::oCalendar := TCalendarControl():New(::oPanel1)
> :nAlign := alClient
>
> :EventChangedEx := "EventChanged"
> :ContextMenu := "ContextMenu"
> :EventDeletedEx := "EventDeleted"
> :OnKeyDown := "OnKeyDown"
> :EventAddedEx := "EventAdded"
> :OnLButtonDown := "OnLButtonDown"
> :OnDblClick := "OnDblClick"
>
> :Create()
> END
>
>
> ::oCalendar:viewtype := xtpCalendarDayView
> oActiveView := ::oCalendar:ActiveView()
> oActiveView:TimeScale(6)
>
> //THis is where we set the theme
> //oTheme := ::oCalendar:??
> //::oCalendar:SetTheme(oTheme)
>
> ::oCalendar:SetDataProvider("Provider=custom")
> ::oCalendar:DataProvider:Create()
> ::oCalendar:DataProvider:Open()
> oEvent := ::oCalendar:DataProvider:CreateEvent()
>
>
> oEvent:StartTime := DateTime()
> oEvent:EndTime := DateTime() + .1
> oEvent:Subject := "6972: STEBRI - Install ADS"
> oEvent:Label := 1
>
> ::oCalendar:DataProvider:AddEvent(oEvent)
> ::oCalendar:Populate()
> ::oCalendar:DayView:ScrollToWorkDayBegin()
>
> RETURN Nil
>
> //---------------------------------------------------------- --------------------
> METHOD EventChanged( oSender ) CLASS TForm1
>
> ::oListBox1:AddItem("An Event/Appointment was edited")
> ::oListBox1:nIndex := Len(::oListBox1:aItems)
> Return Self
>
> //---------------------------------------------------------- --------------------
> METHOD OnDblClick( oSender ) CLASS TForm1
>
> ::oListBox1:AddItem("The Calendar was double clicked")
> ::oListBox1:nIndex := Len(::oListBox1:aItems)
> Return Self
>
> //---------------------------------------------------------- --------------------
> METHOD ContextMenu( oSender, x, y ) CLASS TForm1
>
> ::oListBox1:AddItem("The user requested the context menu, it should
> appear at X: " + AllTrim(Str(x)) + " Y: " + AllTrim(Str(y)) )
> ::oListBox1:nIndex := Len(::oListBox1:aItems)
> Return Self
>
> METHOD EventDeleted( oSender ) CLASS TForm1
>
> ::oListBox1:AddItem("An Event/Appointment was deleted")
> ::oListBox1:nIndex := Len(::oListBox1:aItems)
> Return Self
>
> METHOD OnLButtonDown( oSender, nButton, nShift , x, y ) CLASS TForm1
>
> ::oListBox1:AddItem("The mouse was clicked, the button was: " +
> AllTrim(Str(nButton)) + " Shift Value: " + AllTrim(Str(nShift)) + " X: " +
> AllTrim(Str(x)) + " Y: " + AllTrim(Str(y)))
> ::oListBox1:nIndex := Len(::oListBox1:aItems)
>
> Return Self
>
> METHOD OnKeyDown( oSender, nKeyCode, nShift ) CLASS TForm1
>
> ::oListBox1:AddItem("A key on the keyboard was pressed: ASCII " +
> AllTrim(Str(nKeyCode)) + " Shift Value: " + AllTrim(Str(nShift)) )
> ::oListBox1:nIndex := Len(::oListBox1:aItems)
> Return Self
>
> METHOD EventAdded( oSender ) CLASS TForm1
>
> ::oListBox1:AddItem("An Event/Appointment was added")
> ::oListBox1:nIndex := Len(::oListBox1:aItems)
> Return Self
>
> //---------------------------------------------------------- --------------------
>
>
>
>
>
>