Since I released this control I have received lots of feedback - some kinder than others. Some of the bugs has been found, and even fixed by people using the control. I have not used the control myself for a long time, but it seems that others are using it - so here are an update.
The following improvements have been made:
RemoveAllAppointments bug fixedE_INVALIDARG instead of the
more generic E_FAILThanks goes to the following people:
The new features are implemented in the
ICalendar2 interface, so as not to break
any existing code. A small trick is necessary to access the ICalendar2 interface
of an ActiveX control from Visual Basic.
Dim c2 As ICalendar2 ' The second interface to be accessed Set c2 = Calendar1.Object 'Access the ActiveX object's 'Object' property c2.SetWorkDay startTime, endTime ' Use a function in the interface
Please notice that the ICalendar2 interface cannot be accessed
from typeless scripting languages, because they only support accessing the
default interface of a COM object.

When creating user interfaces it will often be a good idea to try to make them look like Microsoft's. The benefits are that your users immediately will be able to use the program and that they will be familiar with the steps involved in getting some task done. This is the philosophy behind this control that mimics the appointment view as it is implemented in Microsoft Outlook 2000 and XP.
The control is a non-Unicode ATL ActiveX control statically linked to the MFC library. That's right: I'm using MFC for a COM object. I know that it bloats the code, but I'm accustomed to MFC's way of doing GDI stuff, and this control uses a lot of it.
If you do not want to use the ActiveX control, it should be fairly trivial to port it into a C DLL or a just include the source files.
This control and the source code are free to use with commercial- and non commercial software. However you should not sell the source code for profit. I will not take any responsibility for any damage done caused directly or indirectly by this software or an application using it. It is not my problem if it blows up your computer, mutilate your pets or impregnates your wife.
If you decide to redistribute the source code, please include my name and e-mail somewhere in the source. If you create an application with this control, I would appreciate if you would drop me a mail describing what it is.
Thanks to David Hill -
dhill@PrincipiaMathematica.com
for providing the excellent CPinnableDlg used in this component.
This control is not perfect. I have chosen to post it because someone in the Lounge (here at Code Project) was asking for a control like it. Below are some of the issues that I hope will be solved in a later version. If I choose to solve take care of these problems I will of course post an update.
If you have solved any of these issues, please post them on CodeProject or let me know and I will put them into an future update.
The source code is not documented in this article. If you know ATL and MFC you should not have any problems reading it. The code is not obscured by comments, so it should be easy read ;-)
DayView.dll consists of four objects: Calendar, ICalendar2,
IAppointment and DayViewDlg. The properties and methods of each are
documented individually below.
The ICalendar2 interface adds the following metods and properties
Sets the interval in which a "workday" is set. The "workday" is indicated by a bright yellow color.
Object.SetWorkDay(Start As Date, End As Date)The SetWorkDay method event take these arguments:
Part Description StartThe time that the workday should start. Do not specify a date - only time of day. This argument is mandatory. EndThe time that the workday should end. Do not specify a date - only time of day. The value of 'To' should be later than 'From'. This argument is mandatory.
Specify a value of 0 for both to not display a work day interval.
Read/write boolean value.
Decides if the time ruler in the left side of the control will display the hours as military time (0-24 hours) or as AM/PM (0-12 hours).
Default is true
Object.MilitaryTime = false ' Display time in US format
No remarks.
The Calendar object is a visual ActiveX control. It draws the surface and displays the appointments.
Adds an new time limited appointment to the view, with start- and end time, subject and a detailed description (body)
Object.AddAppointment(From As Date, To As Date, Subject As String, Body As String)The
AddAppointmentmethod event take these arguments:
Part Description FromThe time that the appointment should start. Do not specify a date - only time of day. This argument is mandatory. ToThe time that the appointment should end. Do not specify a date - only time of day. The value of 'To' should be later than 'From'. This argument is mandatory. SubjectA short descriptive text that describes the appointment. This argument is mandatory. BodyDetailed information about the appointment. May contain several lines. This argument may be empty.
If you're creating a full day appointment, you do not want to specify start- and end time. instead use the AddFullDayAppointment method.
Adds an appointment to the view. The appointment is not shown in the display area of the control. Instead it is shown above as a "block" with text within it.
Object.AddFullDayAppointment(From As Date, To As Date)The
AddFullDayAppointmentmethod event take these arguments:
Part Description SubjectA short descriptive text that describes the appointment. This argument is mandatory. BodyDetailed information about the appointment. May contain several lines. This argument may be empty.
If you're creating a time limited appointment within the day, and you do not want to specify start- and end time. instead use the AddAppointment method.
Scrolls the specified time into view if it is not visible.
Object.GotoTime(DATE Time)event take this argument:The GotoTime
Part Description TimeThe time of the day that should be scrolled into view. Do not specify a date - only time of day. This argument is mandatory.
The specified time will be scrolled into view, so that it is displayed in the top of the client area of the control.
Clears all appointments from the view. Both full day and time limited appointments are removed..
Object.RemoveAllAppointments(DATE Time)The RemoveAllAppointments method does not take any arguments
none
Read/write long value.
Set the height of each hour in pixels.
Object.HourHeight = 24 ' make each hour 24 pixels in height
The total scrollable area of the control will be 24 hours each
HourHeightpixels high,
This event is triggered when an appointment in the control is clicked.
object_OnClick(Appointment As IAppointment)The
OnClickevent provides this argument:
Part Description Appointment A reference to an appointment object.
The event is triggered both when full day and time limited appointments are clicked.
This event is triggered when an appointment in the control is clicked.
object_OnContextMenu(Appointment As IAppointment)The
OnContextMenuevent provides this argument:
Part Description AppointmentA reference to an appointment object.
The event is triggered both when full day and time limited appointments are right clicked.
This event is triggered when an appointment in the control is clicked.
object_OnDoubleClick(Appointment As IAppointment)The
OnDoubleClickevent provides this argument:
Part Description Appointment A reference to an appointment object.
The event is triggered both when full day and time limited appointments are double clicked.
The IAppointment interface is not a creatable object. It is a read-only
object used for describing an appointment.
This table describes the read-only properties of the IAppointment object.
Property Type Description FromDate The start time of the appointment. If the appointment is full day appointment, the value of this property is undefined. ToDate The end time of the appointment. If the appointment is full day appointment, the value of this property is undefined. FullDayAppointmentBoolean True if this is a full day appointment. SubjectString Short text describing the appointment. BodyString A detailed description of the appointment. This property may be empty.
Read only reference to a Calendar object.
Gets a reference to the Calendar object that is hosted within the dialog box.
Dim cal as Calendar
Set cal = Object.Calendar
The reference to the calendar object is only valid as long as the
DayViewDlgobject is valid. When the reference has been obtained, theCalendarobject can be manipulated like it is described here.
Read/write boolean value.
Determines if the month selector control is visible in the client area of the dialog box.
Object.ShowMonthSelector = true
none
This event is triggered when the user changes the date using the MonthSelector control.
object_OnDateChanged(NewDate As Date, Calendar As Calendar)The
OnDateChangedevent provide these arguments:
Part Description NewDateThe date that is chosen from the month selector object. This date does not contain a time, since it is completely irrelevant. CalendarA reference to the calendar used in the DayViewDlgobject.
The reference to the calendar object can be cached. Just remember that this reference is only valid as long as the
DayViewDlgobject is valid.
| You must Sign In to use this message board. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||