Click here to Skip to main content
Click here to Skip to main content

MS Outlook style Calendar

By , 6 Aug 2005
 
Prize winner in Competition "MFC/C++ Jul 2005"

What is this control?

This is an attempt to reproduce the functionality of MS Outlook Calendar control as it appears in the Calendar view. It supports similar features as the MS Calendar control. This is a work in progress. Study the code in the demo, there you will see how to access the date item data when overriding clicks and double clicks. Below are a couple of screen shots of the control:

Month view

Week view

Introduction

Like many developers I searched within the CodeProject and other sites for a control similar to this one but could not find one so I decided to create my own. I needed a control with similar functionality, but not exactly the same as the Calendar control found in MS Outlook.

This piece or code/control was developed to help me display appointments and tasks in a Real Estate program that I am developing. I did not like the one that was already available but I wanted the look and feel to be similar to MS-Outlook. I hope you will find this control useful and use it in your applications.

What this code provides

  • It is completely written using MFC (no ATL, no Unicode, no .NET). If you want this you are free to modify the code.
  • This code has been tested in Win 2000 and Win XP Professional. I have not tested it on any other versions of Windows, but the only function I would worry about is GradientFill, but according to MSDN it is available as of Win 98 so it would work fine from that version on.
  • This code compiles successfully in VS 6 and VS .NET 2003.
  • This is a work in progress so further additions to the code will be coming.
  • Does not support date items of more than one day. This is a feature I will be adding later.
  • Does not support drag-and-drop of date items from one date cell to another. This is a feature I will be adding later.

One of the things I learned about the original Outlook Calendar control after I created this control was that it can display week views from 1 to 6 weeks at a time. This is one of the modifications I will be making to this control in the near future.

Disclaimer and acknowledgements

This control and the source code are free to be used with commercial and non commercial software. However you are not allowed to sell the source code for profit. The author of this article does not take any responsibility for any damage done or caused directly or indirectly by this source code or an application using this source code.

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 an email describing what it is or a screen shot of it so that I'll know it is being used and may serve as an incentive to continue improving this code/control.

Special thanks go to Tom Furuya for sharing his excellent ColorSpy utility. It was very useful in determining the colors and the magnified views of the mouse pointer locations were critical in getting some of the drawing dimensions correct in this control.

Background

The code and its classes in this article provide all the functionality to not only display a Calendar control in Week or Month views but also to include and display entries (Appointments/Tasks) for the selected dates. Although this code does not provide the dialog boxes or windows necessary to enter entries it does provide you with the methods, properties and overridables necessary to create, modify and delete these entries.

I know this code is not perfect and that someone may actually find a better way to paint the control. I have done all that I can to make sure the painting of different views are as efficient as possible. Of course, if I make further enhancements or fixes to the code or if any of you come up with fixes, I will update this article.

Using the code

  1. The first step in using the CWVDateCtrl class is to add the following files to your project:
    • WVDateCtrl.h/.cpp
    • WVCellData.h/.cpp
    • WVCellDataItem.h/.cpp
  2. You will also need to add a library link to the project.
    • For VS 6, click on Project + Settings... (Alt+F7) to display the Project Settings dialog box.
      1. On the Settings For... dropdown ListBox select All Configurations.
      2. Next, click on the Link tab and enter "msimg32.lib" within the Object/library modules. This library is needed to use the GradientFill Windows function, which is used to highlight the current day of the Month or Week.
    • For VS 7, click on the Project + <ProjectName> Properties... menu option to display the Project Property Pages dialog box.
      1. Select All Configurations from the Configuration: dropdown ListBox.
      2. Click on the Linker option from the tree control.
      3. Next click on Input to display the input values.
      4. For Additional Dependencies enter "msimg32.lib". This library is needed to use the GradientFill Windows function, which is used to highlight the current day of the Month or Week.
      5. Click on the OK button.

You also need to add a custom control object within your FormView or Dialog Window. Make sure to name the class: DBSWMDateCtrl.

Visual Studio 6

Visual Studio .NET 2003

Now we create the variable for this control. Assign the variable name m_WVCtrl by pressing the right mouse button on the Dialog or FormView class and clicking the Add Member Variable... menu option. Enter CWMDateCtrl as the variable type and m_WVCtrl as the variable name.

Next, you need to attach the variable name to the custom control. Within the FormView or Dialog class code, locate the DoDataExchange procedure and add the following code anywhere after the //}}AFX_DATA_MAP line:

DDX_Control(pDX, IDC_CALCTRL, m_WMCtrl);

Now, within the FormView or Dialog box (usually within OnInitialUpdate or OnInitDialog) enter the following lines of code. You can initially display the Calendar control in Month or Week view by simply specifying WV_MONTHVIEW or WV_WEEKVIEW. This method is explained in more detail below:

COleDateTime dtS = COleDateTime::GetCurrentDate();
// Display Calendar in Month View
m_WVCtrl.SetCurrentDate(dtS, FALSE, WV_MONTHVIEW);

or

COleDateTime dtS = COleDateTime::GetCurrentDate();
// Display Calendar in Week View
m_WVCtrl.SetCurrentDate(dtS, FALSE, WV_WEEKVIEW);

If you need to change the view of the control at runtime you can use the SetView method:

m_WMCtrl.SetView(WV_WEEKVIEW, TRUE);

or

m_WMCtrl.SetView(WV_MONTHVIEW, TRUE);

When you compile your code and display the window which contains this custom control you should see the Calendar control displayed in Week or Month view.


Member functions

These functions are in alphabetical order.

void CWMDateCtrl::DeleteAllItems()

Description

    This method is used to delete all the data items related to this control.

Syntax

    m_WVCtrl.DeleteAllItems();

BOOL CWMDateCtrl::DeleteItem(long nItem)

Description

    This method is used to delete a specific data item as specified by the nItem parameter. The parameter is the ID number of the data item added to the custom control with the InsertItem method.

Syntax

    void CWeekViewDlg::OnCellDblClick(NMHDR *pNotifyStruct, 
                                             LRESULT *pResult)
    {
        NM_WVCELLDATA *pData = (NM_WVCELLDATA *)pNotifyStruct;
    
        if (pData->pItem != NULL)
             m_WVCtrl.DeleteItem(pData->nItem);
    }

COleDateTime CWMDateCtrl::GetCurrentDate()

Description

    Returns the current date for this control. The current date is the highlighted cell within the Week or Month view.

Syntax

    COleDateTime dtCurDate = m_WVCtrl.GetCurrentDate();

void CWMDateCtrl::GetDateRange(COleDateTime *pStartDate, COleDateTime *pEndDate)

Description

    Use this method to retrieve the current start and end date based on how the control is displayed. If the control is displayed in Month view, as pictured above, this method will return the following values: pStartDate will equal 1/31/2005 and pEndDate will equal 3/13/2005.

    If the control is displayed in Week view, as pictured above, this method will return the following values: pStartDate will equal 2/14/2005 and pEndDate will equal 2/20/2005.

Syntax

    // Display Date Range!!
    CString strBuf;
    COleDateTime dtS, dtE;
    
    m_WVCtrl.GetDateRange(&dtS, &dtE);
    strBuf.Format("Date Range: %s - %s", 
                 dtS.Format("%m/%d/%Y"), 
                 dtE.Format("%m/%d/%Y"));

int CWMDateCtrl::GetDay()

int CWMDateCtrl::GetMonth()

int CWMDateCtrl::GetYear()

Description

    This method returns the day, month or year of the current date.

Syntax

    int nCurrentDate = m_WVCtrl.GetDay();
    int nCurrentMonth = m_WVCtrl.GetMonth();
    int nCurrentYear = m_WVCtrl.GetYear();

int CWMDateCtrl::GetView()

Description

    This method returns one of two values WV_WEEKVIEW or WV_MONTHVIEW. This indicates the current display state of the control.

Syntax

    if (m_WVCtrl.GetView() == WV_WEEKVIEW)
        m_WVCtrl.SetView(WV_MONTHVIEW);
    else
        m_WVCtrl.SetView(WM_WEEKVIEW);

DWORD CWMDateCtrl::GetItemData(long nItem)

Description

    Returns a 32-bit application-specific value associated with the specified item.

Syntax

    NM_WVCELLDATA *pData = (NM_WVCELLDATA *)pNotifyStruct;
    
    if (pData->pItem != NULL)
        DWORD dwValue = m_WVCtrl.GetItemData(pData->nItem);
    ...

long CWMDateCtrl::InsertItem(COleDateTime dtStart, COleDateTime dtEnd, CString strLine /*=""*/, int nImage /*=-1*/)

Description

    Inserts a date item into the custom control. For an item to be displayed within the control the first parameter of this method should be within range of the date set by the SetCurrentDate method. The next two parameters are optional and are used to specify if the date item time is displayed using regular (FALSE) or military (TRUE) time and which image from an attached image list is used when painting the date item.

Syntax

    // Set WVCtrl date for week display
    dtS.SetDate(2005, 2, 19);
    m_WVCtrl.SetCurrentDate(dtS, FALSE, WV_MONTHVIEW);
    
    dtS.SetDateTime(2005, 2, 14, 8, 30, 0);
    dtE.SetDateTime(2005, 2, 14, 9, 45, 0);
    m_WVCtrl.InsertItem(dtS, dtS, "Monday Appointment", 0);
    
    dtS.SetDateTime(2005, 2, 15, 22, 30, 0);
    dtE.SetDateTime(2005, 2, 15, 23, 45, 0);
    nItem = m_WVCtrl.InsertItem(dtS, dtE, "Tuesday Task", 1);

BOOL CWMDateCtrl::IsMilitaryTime()

Description

    Returns a TRUE or FALSE value to determine if the time portion of the date entries are displayed using military time (TRUE) or regular time (FALSE).

Syntax

    if (m_WVCtrl.IsMilitaryTime())
        m_WVCtrl.SetMilitaryTime(FALSE);
    else
        m_WVCtrl.SetMilitaryTime(TRUE);

void CWMDateCtrl::SetBkColor(COLORREF clrBk)

Description

    Changes the background color of the Calendar control.

Syntax

    m_WVCtrl.SetBkColor(RGB(255, 0, 0); // Set to red 
                                        // background color

void CWMDateCtrl::SetCurrentDate(COleDateTime dtDate, BOOL bMilitaryTime /*= FALSE*/, int nView /*= WV_WEEKVIEW*/)

Description

This method is used to specify the date that is to be used as the current date, if we are displaying the date item times using Military or Regular time and the type of view to be used. Using this method you have to specify a date, preferably the current date (this would be the highlighted date within the control). This control would take this date and determine which other dates are to be painted based on the specified view.

Syntax

    COleDateTime dtToday = COleDateTime::GetCurrentTime();
    
    // Display calendar in month view and 
    // today's date would be highlighted.
    m_WVCtrl.SetCurrentDate(dtToday, FALSE, WV_MONTHVIEW);

void CWMDateCtrl::SetFont(CString strFName, int nSize)

Description

Use this method to change the default font and font size to be used to paint the Calendar control.

Syntax

    m_WVCtrl.SetFont("Verdana", 14);

void CWMDateCtrl::SetImageList(CImageList *pImgList)

Description

    Use this method to attach an image list to the Calendar control. The example below shows how to attach a 256 color 16 X 16 bitmap to the control.

Syntax

    // Setup the Calendar control
    CBitmap bmpImgSm;
    m_ImgList.Create(16, 16, ILC_COLOR24 | ILC_MASK, 0, 1);
    
    // Load 256 color bitmap containing the images...
    bmpImgSm.LoadBitmap(IDB_BMPREMINDER);
    
    // Place bitmap into image list...
    m_ImgList.Add(&bmpImgSm, RGB(0, 255, 0));
    
    // Attach image list to the Calendar Control
    m_WVCtrl.SetImageList(&m_ImgList);

void CWMDateCtrl::SetItemColor(long nItem, COLORREF clrItem)

Description

    Use this method to set or change the background color of individual date items. This is useful to identify the type of appointments and tasks based on color.

Syntax

    dtSDate.SetDateTime(2005, 8, 6, 12, 00, 0);
    // 45 minutes for lunch
    dtWDate.SetDateTime(2005, 8, 6, 12, 45, 0);    
    // Display as a task, use task image
    int nItem = m_WVCrtrl.InsertItem(dtSDate, dtEDate, 
                                "Lunch with Rolando", 1); 
    // Set appointment to green color
    m_WMCtrl.SetItemColor(nItem, RGB(0, 255, 0)); 
    
    
    dtSDate.SetDateTime(2005, 8, 6, 8, 30, 0);
    // 2 hour appointment
    dtWDate.SetDateTime(2005, 8, 6, 10, 30, 0);    
    nItem = m_WVCrtrl.InsertItem(dtSDate, dtEDate, 
                                 "Sales meeting", 0);
    // Set appointment to blue color
    m_WMCtrl.SetItemColor(nItem, RGB(0, 0, 255));

void CWMDateCtrl::SetItemData(long nItem, DWORD dwData)

Description

    This function sets the 32-bit application-specific value associated with the item specified by nItem.

Syntax

    int nItem = m_WVCtrl.InsertItem(dtS, dtE, "Lunch time");
    // 999 use this internal value
    m_WVCtrl.SetItemData(nItem, 999);

void CWMDateCtrl::SetMilitaryTime(BOOL bMil)

Description

    Use this method to set or change the display of date item times. Setting the parameter to TRUE will paint the date item times using Military time, otherwise Regular time is used. This method affects the entire Calendar control.

Syntax

    m_WVCtrl.SetMilitaryTime(TRUE);

void CWMDateCtrl::SetView(int nV, BOOL bRedraw /*=TRUE*/)

Description

    Use this method to change the way the Calendar control is painted. The values which can be used are WV_WEEKVIEW or WV_MONTHVIEW.

Syntax

    if (m_WVCtrl.GetView() == WV_WEEKVIEW)
        m_WVCtrl.SetView(WV_MONTHVIEW);
    else
        m_WVCtrl.SetView(WM_WEEKVIEW);

Override functions

Currently, there are only two messages that you can override in order to interact with this control. The Calendar control will notify the parent window with a NM_CLICK and NM_DBLCLK. To override these notification messages follow these instructions:

  1. Add the following PROTECTEDmember function to your FormView or dialog box to process double click notifications from the Calendar control:
    afx_msg void OnCellDblClick(NMHDR *pNotifyStruct, 
           LRESULT* pResult); (Left mouse Double click)
    afx_msg void OnCellClick (NMHDR *pNotifyStruct, 
                  LRESULT* pResult); (Left mouse Click)
  2. Next add the following line to your message map:
    ON_NOTIFY(NM_DBLCLK, IDC_CALCTRL, OnCellDblClick)
    ON_NOTIFY(NM_CLICK, IDC_CALCTRL, OnCellClick)
  3. Edit the OnCellDblClick/OnCellClick member function. To access the Calendar information you need to cast pNotifyStruct to NM_WVCELLDATA.
    NM_WVCELLDATA *pData = (NM_WVCELLDATA *)pNotifyStruct;

NM_WVCELLDATA notification structure

    typedef struct tagNM_WVCELLDATA {
        NMHDR hdr;
        CWVCellData *pCell;
        CWVCellDataItem *pItem;
        int   iRow;
        int   iColumn;
        BOOL bDNFClicked;
        long nItem;
    } NM_WVCELLDATA;

CWVCellData *pCell;

    This member variable contains all the information regarding the actual date cell of the Calendar control. You have access to many functions and procedures which directly affect the appearance and behaviour of the Calendar date cell.

    Take a look at the WVCellData.h and WVCellData.cpp files for more information on this Calendar object. I believe all the procedures and functions are self explanatory.

CWVCellDataItem *pItem;

    This member variable is usually NULL unless the user clicks or double clicks on a data item within a date cell of the Calendar control. You have access to functions and procedure which directly affect the particular date item data.

    Take a look at the WVCellDataItem.h and WVCellDataItem.cpp files for more information on this Calendar date item object. I believe the procedures and functions are self-explanatory.

int iRow;

int iCol;

    These two member variables contain the mouse pointer coordinates where the actual click or double click has occurred.

BOOL bDNFClicked;

    This is a special member variable. This member variable will have a value of TRUE only when the user clicks on the Does Not Fit rectangle which is located at the bottom right part of any Calendar date cell which can't display all of the date items within the available cell area.

    When the user clicks on this object, the Calendar control will notify the parent window as if the user has double clicked the cell at which point this member variable will be set to TRUE. It is up to you to decide how you want to handle this. I use this feature to change the Calendar view from Month to Week view.

long nItem;

    This is the ID number given to the Calendar date item (pItem) when the InsertItem function is used.

    Look at the OnCellClick and OnBtndeleteitem member functions within the demo program to find out how I have used this member variable (CalCtrlDlg.cpp).

History

  • July 11th, 2005 - Began development of this code.
  • July 18th, 2005 - Completed initial development.
  • August 6th, 2005 - Released to CodeProject.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Rolando E. Cruz-Marshall
CEO Independent Contractor
United States United States
Member
I have been programming Windows applications since 1990 (v 3.0). Remember Turbo C/C++ and Microsoft C/C++? Both were in Text mode... WTF | :WTF:

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionIt's a good control,but hava several bugmemberkalrey9 Aug '11 - 20:16 
Firstly,thanks for sharing the good control.But there is also several bug.
I realize you just have only one data panel,all data just build with the only panel although those data belong to different panel.(There is a simple example: If you add some data items to the date cell 2011/06/27, then you switch the panel to 2011/08/01,you will find the data items belong to 2011/06/27 appear in the cell 2011/08/01).
I'm solve this problem with:
1.Add a map.This map just store those CWVCellData which had added data.And those cell which have no data item just mapping to your old panel.
2.Rewrite the function GetCellByID(),parse the ID to return either old panel cell or the new map cell.
3.Rewrite the function GetCellByDate(),just do the same to the step 2.

I'm sorry I'm so poor in English.
GeneralFix to GetItemData()memberMember 371720425 Feb '11 - 4:37 
WMDateCtrl.cpp:
 
DWORD CWMDateCtrl::GetItemData(long nItem)
{
DWORD dwData;
// Locate the CellDataItem identified with nItem
POSITION pos = m_CellList.GetHeadPosition();
CWVCellData *pCellData = NULL;
 
while (pos != NULL)
{
pCellData = (CWVCellData *)m_CellList.GetNext(pos);
// View all CelDataItems for this CellData
if (pCellData->GetItemData(nItem,&dwData)) return(dwData);
}
return NULL;
}
 
WVCellData.cpp:
 
DWORD CWVCellData::GetItemData(long nItem, DWORD *dwData)
{
CWVCellDataItem *pItem = NULL;
POSITION posItem = m_ItemList.GetHeadPosition();
 
while (posItem != NULL)
{
pItem = (CWVCellDataItem *)m_ItemList.GetNext(posItem);
if (pItem->GetItemID() == nItem)
{
// We have the item!!
*dwData = pItem->GetItemData();
return(1);
}
}
return NULL;
}

Generaldo you have new version for unicodememberlogi00123 Dec '09 - 2:23 
thank you
GeneralVB6 usagememberMTeefy30 Nov '09 - 7:06 
Hi,
 
Forgive my ignorance here as a VB6 bod.
 
I downloaded the demo files and within VS 2005 built the project resulting in a debug folder entry mfc.exe which runs fine but how do i make this project into a DLL that i could use from VB6.
 
This would be fantastic as a control for appointment purposes if it could be used the way the dayview control does: DayView - An Outlook Like Appointment View[^]
 
Any advice or better still if any-one has already done this month view code could you post the dll/ocx and some samples on how to use it?
 
Thanks
Martin
GeneralSetTime() shows DATE instead of TIME in both controls...memberAlexEvans27 Aug '08 - 22:09 
Hi Rolando,
 
In the small pop-up dialog, it shows correctly the TIME in your sample application,
BUT - after copying te required files into my application this shows the DATE instead, in both the FROM and TO fields.
 
I checked ALL the attributes of this doalog in the sample, and in my application, and they are the same.
 
I did make a small change in the OnInitDialog() just so that it shows the DATE in thye caption in dd/mm/yyyy format instead of the US format, but even after changing it back, it still missbehaves...
 
Below is the code fragment of the OnInitDialog(), I am checking the return value as you can see, and it returns '1' in both cases...
 
Hope you can help me figure out why and how to fix it.
 
Thanks in advance
Alex
 
BOOL CDlgDateItem::OnInitDialog()
{
CDialog::OnInitDialog();
 
CString strBuf;
BOOL bRC = 0;
 
if (bAddMode)
strBuf.Format("Add Date Item - %s", dtSDate.Format("%d/%m/%Y"));
else
strBuf.Format("Modify Date Item - %s", dtSDate.Format("%d/%m/%Y"));

SetWindowText(strBuf);

m_Subject.SetWindowText(strSubject);
bRC = m_FromTime.SetTime(dtSDate);
bRC = m_ToTime.SetTime(dtEDate);
GeneralNIce job, but...memberAlexEvans24 Aug '08 - 17:12 
Just wonder, how do I get it to START NOT from the current DATE,
 
I tried a few things, such as initiating the date to something else - but it keeps coming up as TODAY in the view...
 
Any help?
 
Cheers
Alex
GeneralRe: NIce job, but...memberRolando E. Cruz-Marshall25 Aug '08 - 1:49 
You should be able to change the start date by using the SetCurrentDate method.
 
Example,
 
// From the demo project... CCalCtrlDlg.cpp file
// Comment line 142
//m_WMCtrl.SetCurrentDate(COleDateTime::GetCurrentTime());
 
// Add this code (line 143) - Change the date to 2/19/2007
COleDateTime dtDate(2007, 2,19, 0, 0, 0);
m_WMCtrl.SetCurrentDate(dtDate);

 
Hope this help.
 
Rolando Suspicious | :suss:

GeneralRe: NIce job, but...memberAlexEvans25 Aug '08 - 2:46 
Thank you,
 
I figured it out in the mean time
 
Cheers
Alex
QuestionVS 2005 control librarymemberpseudokris11 Feb '08 - 13:48 
I realize this thread seems to have died off a couple of years ago. However, I am working on a project for a friend and I would very much like to use this control.
 
I am a C# programmer of moderate knowledge and I have been trying to create a workable Windows form control or something so that I can utilize this Calendar Control in my C# project.
 
Has anyone already built a COM for this control that can be used in VS 2005? If not, can anyone give me a bit of guidance on how I would go about making one myself? I have tried creating an MFC DLL. I am able to compile but unable to actually use the dll once created... perhaps I'm missing something obvious. I have tried creating a CLR Windows Form Control Library. Which won't even compile (generating 480+ compile errors).
 
Thank you for your time...
 
Cheers,
-pseudokris
QuestionUse this control in a vb.net 2003 projectmemberdbaratelli14 Nov '06 - 6:56 
I think this control is excelent.
I want to use it in a vb.net 2003 project in a win form. How can I use it? I am begginer programmer. Please, tell me what to do to use it. (step by step if possible)
Thanks in advance.
d.b.
GeneralSmall bugmemberIce_2k16 Oct '06 - 1:21 
Another small problem I found... in function CWMDateCtrl::OnLButtonDown, the NM_CLICK event is only sent to the parent (SendMessageToParent(...)) when an item has been clicked... so if you click an item in a cell and then click an empty cell the first item is unselected but if you hit "Delete" the item will be deleted because the parent was not notified that the user clicked another cell in the meanwhile.
 
To make mistakes is normal.
To blame your computer for your mistakes, it's more than normal, it's NATURAL.

QuestionWow! Excellent control!memberWillem_Le_Roux10 Jul '06 - 5:12 
Hey Ronaldo!
 
Great control! OMG | :OMG: It looks smashing and I am looking forward to using it in my own applications. I have seen on the boards that you are thinking about incorporating the day view into your application. Super idea! Keep me posted!
 
Now, there are a few questions that I would like to ask. If I am in the month view and I filled up all the space with appointments/tasks, how do I have a look at the appointments/tasks that is not visible? You say that you use “BOOL bDNFClicked” to switch to week view. If already in week view, could you make it switch to day view? Could you perhaps make a little list appear with all the appointment items that are not displayed? And then when you click on an item in that list, it shows the details for those specific entries.
 
I LOVE your control and please keep me posted as to when you are planning any updates! I like it A LOT! I see you have won an award for this one as well! Congratulations!
 
Willem Le Roux
AnswerRe: Wow! Excellent control!memberRolando E. Cruz-Marshall10 Jul '06 - 15:05 
Hey Willem!
 
Thanks for your kind words.
 
As fas as the Day View goes, I worked on it for a while but the coding approach was wrong since the control took a while to draw itself. I also had scrolling problems. Unfortunately I have not continued development on this control and I currently do not have the time for it. Frown | :(
 
I can suggest that when clicking on the DNF button, on the bottom right corner of the month cell, you can query the database and display a dialog box with the list of all items for the day cell. You could do the same in the week view, if you want. The control notifies the parent window when this button is clicked. (Make sense? D'Oh! | :doh: )
 
I am currently developing a new version of a program I've developed and will propably be using this control. If I make any changes to the code I will post it here once again. (No promises though! WTF | :WTF: )

 
Rolando Suspicious | :suss:
GeneralRe: Wow! Excellent control!memberWillem_Le_Roux10 Jul '06 - 22:22 
Hey Ronaldo!
 
Well, as far as the Day View goes, that is unfortunate. I suppose that I could try and incorporate the "day pilot" article (also found on codeproject) into this control... I think.
 
Thanks for the DNF button suggestion. I will be sure to give that a go. Like I said, great control! Keep up the good work!
 
Cheers
 
Willem Le Roux
GeneralSimilar control for ASP.NET (open-source)memberDan Letecky28 Jun '06 - 10:30 
I've made a similar control for ASP.NET. But instead of a month view it focuses on day view (multiple days view is also supported).
 
You might want to check it out:
Homepage: DayPilot Calendar - Home
Screenshots: DayPilot Calendar - Screenshots
Live demo: DayPilot Calendar - Live Demo
 
--
My sites for smart .NET developers:
DayPilot - Open-source Outlook-like calendar control for ASP.NET
DotLucene - The fastest open source fulltext search engine for .NET
Seekafile Server - Flexible open-source search server
DotNetFirebird - Using Firebird SQL in .NET

QuestionWhy don't help us?????memberpippobuado5126 May '06 - 21:23 
I don't understand why the author of this components (about all of them) don't replay to our help question.
I know, you have some else to do, ok, but, what about a faq (for example)?
A small work for you can help many of us Wink | ;)
 
Thanks
QuestionGreat work - let's try printing again...memberarnoldkempt18 May '06 - 8:01 
This was asked back in '05 and never got a response. I've been trying to get this control to print to no avail. Can anyone direct me with a high-level overview on how to do it. Thanks.
 
Arnie
QuestionExcellent !!...Just wondered though ??membersi_6926 Feb '06 - 6:02 
Hey,
 
Great article , and congrats on the award !!
 
I was interested to see how you implemented it in your Estate Agent app, so i downloaded it.Looks good and i shall be using the control in my on apps
 
Just going off on a tangent here but one thing i noticed in your Estate agent app was the menu on the left (the Agents Desktop/Tools menu)
 
I have been looking to implement such a menu myself, but was unsure how it was done Unsure | :~
 
I just wondered if you had any tips you could provide on how you did that ?Confused | :confused: any info/help/links would be much appreciated, or maybe an article Wink | ;)
 
I have searched the articles and cant find anything like it ??
 
Thanks, and congrats again
 
Si
AnswerRe: Excellent !!...Just wondered though ??memberRolando E. Cruz-Marshall26 Feb '06 - 10:24 
Hi,
 
Glad to hear you are going to use the control.
 
Regarding the left side of the screen (Agent Desktop and Agent Tools) I used to code from another developer right here in CodeProject. The control is called DirectUI Window as in XP system folder. This excellent control is developed and maintained by Alexander Bischofberger, you can read about his work here[^].
 
Hope this helps you out.
 
Rolando Suspicious | :suss:
GeneralSmall bug in GetDateRangememberTom Archer - MSFT19 Feb '06 - 14:55 
Great class! It's definitely made my app much better looking and usable.
 
Having said that, I have found one small bug in GetDateRange.
 
It correctly "walks" back from the current date until the day == Monday (which to COleDateTime::GetDayOfWeek is 2).
COleDateTime dtDate = dtCurrentDate;
while (dtDate.GetDayOfWeek() != 2)
dtDate -= 1;
pStartData = GetCellByDate(dtDate);

 
However, for end date, it then tries to walk forward until the COleDateTime::GetDayOfWeek == 7.
 
The problem with that is that the calendar displays Sunday as the last day of the week and 7 for the COleDateTime
 
control is Saturday. Therefore, in cases where the current day is Sunday, the control incorrectly returns the
 
following week's Saturday as the end of the current week.
 
In my own version of the class, I solved this by simply adding 6 to the correctly determined start of week value.
 
dtDate += 6;
pEndData = GetCellByDate(dtDate);

 
Tom Archer (blog)
Program Manager
MSDN Online (Windows Vista and Visual C++)
MICROSOFT
GeneralRe: Small bug in GetDateRangememberRolando E. Cruz-Marshall19 Feb '06 - 16:17 
Thanks for using this control. Big Grin | :-D I will make sure I fix the code. I have not had the time to spend to update and repost this control. Sigh | :sigh: As soon as time permits I will do so.

 
Rolando Suspicious | :suss:
GeneralNew entries don't displaymemberTom Archer - MSFT18 Feb '06 - 13:41 
If I'm running the debugger, the new item displays
 
However, if I'm not it doesn't display *until* I click anywhere on the control.
 
Any ideas?
 
Tom Archer (blog)
Program Manager
MSDN Online (Windows Vista and Visual C++)
MICROSOFT
 
-- modified at 19:41 Saturday 18th February, 2006
GeneralUse in VBmembertassieboy9 Feb '06 - 17:12 
Can this control be used in VB.NET ?
GeneralRe: Use in VBmemberyangyancheng7 Jul '06 - 19:09 
First ,use vs2005.
then use VC.NET 2005 to write a .net usercontrol which contains this mfc control .(because VC 2005 can use both clr and mfc in the same project)
third invoke the .net usercontrol in vb.net.
I have done this these days, and the vb program works well.
 
sfcyyc
GeneralWay to go Rolando!memberc0d3m@n8 Feb '06 - 13:38 
This was just what I was looking for. You mentionned that you were going to add multi-day event support and drag and drop... I'd be super duper interested in those extra features. Have you had the chance to add those yet? Will you share them as well? =)
 
Thank you so much! Again, terrific job and congratulations on the award!
 
Mike
QuestionNeed Help, pleasememberpippobuado518 Feb '06 - 1:57 
Hi,
can someone tell me how to use this nice style Calendar into a vb .net project?
Thanks all
 
-- modified at 7:59 Wednesday 8th February, 2006
GeneralA little problemmemberfvan24 Jan '06 - 4:45 
In your code,when the app sends the WM_LBUTTONDOWN and WM_RBUTTONUP message,it would redraw the whole frame.Thus,A flash occurs.
GeneralRe: A little problemmemberRolando E. Cruz-Marshall24 Jan '06 - 4:49 
Hi, I am aware of this design flaw Unsure | :~ but I have not had the time to go back and address this issue. Frown | :(
 
Rolando Suspicious | :suss:
GeneralShowing a different monthmemberTWS_Dave17 Jan '06 - 3:25 
Hi
 
Like most of the other comments I think this control is great, but I would like some advice on the best way to show a month other than the current month.
 
The only way I can see to do this is to set the current date to a date within the month to be shown but this would highlight a cell as if it were today and I would like to avoid this.
 
Has anybody got any other ideas - Am I missing something obvious here??Confused | :confused:
 
Thanks for your help
 
Dave
GeneralRe: Showing a different monthmemberIce_2k16 Oct '06 - 0:24 
Hi,
 
I also needed that so I added another member to WMDateCtrl, called dtTodayDate. This is the member used to highlight "today" and dtCurrentDate is only used to determine the range currently displayed. In the DrawWeekCellHeaders and DrawMonthCellHeaders functions, replace "if (pCell->GetCellDate() == dtCurrentDate)" with "if (pCell->GetCellDate() == dtTodayDate)". Also you need to add Set/Get functions for dtTodayDate.
 
To make mistakes is normal.
To blame your computer for your mistakes, it's more than normal, it's NATURAL.

GeneralRe: Showing a different monthmemberTWS_Dave16 Oct '06 - 0:38 
Thanks for that. I never did get around the problem so will now implement your suggestionSmile | :)
 

GeneralRe: Showing a different monthmemberIce_2k16 Oct '06 - 0:53 
Remember to remove the hour/minute/second information from the parameter received by SetTodayDate().
 
Another thing... doing this will bring up another problem... when using SetCurrentDate(), all cells and items colors are restored to the default values... which will cause a problem for items with custom colors.. To fix this I added a "bCustomColor" member to items which I set after changing their color to a color of my choice... this way I can differentiate between items with user custom color and items that just change color between those 2 shades for separate months.
 
To make mistakes is normal.
To blame your computer for your mistakes, it's more than normal, it's NATURAL.

GeneralRe: Showing a different monthmemberIce_2k16 Oct '06 - 1:13 
Navigating through the calendar...
 
void CCalCtrlDlg::OnButtonNext()
{

COleDateTime dtCurrDate = m_WMCtrl.GetCurrentDate();
dtCurrDate += (m_WMCtrl.GetView() == WV_WEEKVIEW ? 7 : 30);
m_WMCtrl.SetCurrentDate(dtCurrDate, FALSE, m_WMCtrl.GetView());

}
 
To make mistakes is normal.
To blame your computer for your mistakes, it's more than normal, it's NATURAL.

Generalplease help mememberfandijunior10 Jan '06 - 9:55 
Hi
I'm developing an application in c# and I am going to need your Calendar. I downloaded the example and is very good for me but i read that you were working in drag and drop:->, if you have that option already made it will be very helpful for me!
I appreciate your help;)
bye

GeneralGreat code, two trifle problems.memberFzz13 Dec '05 - 19:24 
Tks for yr great attribution to these. I found two little problems in your code:
1.function GetDateRange(....),which can not return true Enddate in weekview.I trace and find that enddate always less than one:
void CWMDateCtrl::GetDateRange(COleDateTime *pStartDate, COleDateTime *pEndDate)
{
...
while (dtDate.GetDayOfWeek() != 7)
dtDate += 1;
dtDate+=1; //Add this line
...
}

 
2.function GetItemData(...), which have problems. I read your code and found problems. In GetItemData, you check every CWVCellData and return pCellData->GetItemData(nItem), if not found, it always return NULL(0). I revised as follows:
while (pos != NULL)
{
pCellData = (CWVCellData *)m_CellList.GetNext(pos);
// View all CelDataItems for this CellData
//return pCellData->GetItemData(nItem); //Remark this line
DWORD dwValue = pCellData->GetItemData(nItem); //Add these two
if(dwValue != -1) return dwValue; //If not found, go on and find another CellData.
}
return -1;

 
also, change:
DWORD CWVCellData::GetItemData(long nItem)
{
CWVCellDataItem *pItem = NULL;
POSITION posItem = m_ItemList.GetHeadPosition();
 
while (posItem != NULL)
{
pItem = (CWVCellDataItem *)m_ItemList.GetNext(posItem);
if (pItem->GetItemID() == nItem)
{
// We have the item!!
return pItem->GetItemData();
}
}
return -1; //change this, return -1 instead of 0, which maybe set.
}

 
Anyway,thanks for your code.
 
Benny fun
GeneralRe: Great code, two trifle problems.memberRolando E. Cruz-Marshall14 Dec '05 - 1:30 
Thanks for pointing this out and thanks for providing corrections.
 
Rolando Suspicious | :suss:
GeneralRe: Great code, two trifle problems.memberFzz23 Dec '05 - 1:41 
Anybody has implemented tooltip for the great control. I have tried but failed? If do ,pls post here. Tks a billion.Smile | :)
 
Benny fun
GeneralDay View UpdatememberFuture5 Oct '05 - 2:12 
This is really a great component.
But for my software i need day-view as well.
 
I know that you are quite busy and dont want to rush you.
But do you have an approx. date for an update with this feature?
 
It would be silly to try to program it myself and in 2 weeks you have an update with all i desire and with better quality than i could produce myself Smile | :)
 
Thanks a lot
GeneralRe: Day View UpdatememberRolando E. Cruz-Marshall5 Oct '05 - 2:19 
I have been pulled away from this proyect because of work. I got to the pointwhere I did have a Day View being displayed but when I began to add in the Date Items and changed the Day view to display in intervals of 15+ minutes performance dropped significantly.
 
I have not had the time to revisit this code. I may need to rewrite it. I would not feel comfortable posting a half working DayView within the control.
 
Rolando Suspicious | :suss:
QuestionHow do you print itmemberGerard Nicol4 Oct '05 - 20:33 
Any idea how you print it?
GeneralCongrats and the alternative ;)memberSerega26 Sep '05 - 22:52 
Hi Rolando,
 
Congratulations for being the winner!
 
BTW, if someone is interested, there are good alternative implementations of the MS Outlook style Calendar, for example at http://www.codejock.com/products/calendar/[^]
 
--
Best regards,
Serge Wink | ;)
GeneralRe: Congrats and the alternative ;)memberRolando E. Cruz-Marshall27 Sep '05 - 19:34 
Serega wrote:
Congratulations for being the winner!
 
Thanks. :->
 
Although this control can't compare to the offerings at the link you provided. Your control is a way better implementation of the calendar control. Wink | ;)
 
Rolando Suspicious | :suss:
Questionsave and load?memberbcde0319113020 Sep '05 - 6:25 
I love it very much!But I have a problem.Can't it save our tasks or appointments?
I hope it can load all of items automatically when we use it next time.
How should I do this? Can you help me? Thank you very much Smile | :)
AnswerRe: save and load?memberRolando E. Cruz-Marshall20 Sep '05 - 10:34 
Hi,
 
Glad you like this control!! Big Grin | :-D
 
I did take some time in deciding what features to include with this control. I decided early on that it would not be appropriate for me to include code for saving and loading date items. Not to save on development time but because I want the application developer (you) to decide how and in what way you want to save your date items.
 
Look at the InsertItem method. This is the minimum amount of information you need to store within your application's data file. When the application displays this control you can query your data file and use the InsertItem method for each date item you want included in the calendar. You can insert date items even if they are outside of the date range being displayed in the Calendar control. They will display if the date item date is part of the displayed calendar. I believe this gives you more control over what Date Items you want to display in the calendar.
 
If you want to save a comment or a more detailed description of the date item (appointment or task) you can do this and display the information within a Task dialog box (for example) when the user double clicks the date item.
 
Another example: if you want to display date items for only a specific user or type of client, etc. You can do this. If I were to control loading and saving of data you would not have this level of control.
 
Hope this makes sense. Smile | :)
 
Rolando Suspicious | :suss:
GeneralRe: save and load?memberbcde0319113023 Sep '05 - 3:34 
Thank you very much!I almost done about saving and loading tasks and appointments!
 
But I have a small problem.How can I get all of my tasks and appointments in the calendar?
Maybe yesterday I have a task,and tomorrow I have an appointment.I hope I can get all of
the items,and then I can save them outside.
 
I really don't know how to get all items once.If I delete a item in the calendar,I hope
I can get all texts,and rewrite my data outside.Hope you can help me how to use function
about get all of my items.Thank you very muchSmile | :)

GeneralRe: save and load?memberRolando E. Cruz-Marshall25 Sep '05 - 16:28 
Hi,
 
The reality is that it never occured to me to add this functionality! D'Oh! | :doh:
 
Modify the WMDateCtrl.cpp file by using the "Add a Member Function" and add the following two member functions:
 
// Returns total number of Date Items
int CWMDateCtrl::GetItemCount()
{
     return m_ItemList.GetCount();
}
and
// Returns Date Item by position
CWVCellData * CWMDateCtrl::GetDateItemByPos(int nPos)
{
   POSITION pos = m_CellList.GetHeadPosition();
   CWVCellData *pData = NULL;
   int nCount = 0;
 
   while (pos != NULL)
   {
      pData = (CWVCellData *)m_CellList.GetNext(pos);
      if (nCount ++  == nPos)
         break;
   }
   return pData;
}
Use these two function within a for loop and get each of the CWVCellData structures. I hope this is what you are looking to accomplish.
 
Rolando Suspicious | :suss:
GeneralDrag and DropmemberBernhard17 Aug '05 - 19:48 
I know, many people loath Lotus Notes.. but it would be absolutely great to change the Date of an appointment by Drag and Drop.
 
Just an idea how to expand the functionality of the control.
 

All the label says is that this stuff contains chemicals "... known to the State of California to cause cancer in rats and low-income test subjects."
Roger Wright
http://www.codeproject.com/lounge.asp?select=965687&exp=5&fr=1#xx965687xx
GeneralRe: Drag and DropmemberRolando E. Cruz-Marshall18 Aug '05 - 2:39 
Hi,
 
Bernhard wrote:
...but it would be absolutely great to change the Date of an appointment by Drag and Drop.
 
I agree, Drag and drop is a feature I would like very much to add to this control. Project and work demands do not leave me with much time at this moment. Believe me, this is one feature I will eventually get to.
 
Thanks for the interest! Big Grin | :-D
 
Rolando Suspicious | :suss:
QuestionC# ?sussAnonymous17 Aug '05 - 3:34 
Your profile says that you are using C# now. Have you considered porting this project to C#?
AnswerRe: C# ?memberRolando E. Cruz-Marshall17 Aug '05 - 8:19 
The profile says I'm looking into C# but I honestly have not got very far with it. Busy with work.
 
Rolando Suspicious | :suss:

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web02 | 2.6.130516.1 | Last Updated 6 Aug 2005
Article Copyright 2005 by Rolando E. Cruz-Marshall
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid