Click here to Skip to main content
Licence 
First Posted 2 Aug 2005
Views 73,887
Bookmarked 38 times

MyCalendar Control

By | 7 Aug 2005 | Article
An article on writing a calendar control using the Windows SDK.

MyCalendar test application

Introduction

This article is about the MyCalendar control programmed with Windows SDK. It is developed to be easy to use in different types of applications. It represents dates according Gregorian calendar rules. Also supports Easter date calculation for Julian and Gregorian calendars and Gregorian representation of this calculation. Covers period from year 1582 (when Gregorian calendar was established) to year 4099.

Background

This is a clone of the MFC CDateTimeCtrl with some advantages.

Using the code

To use the source provided, one must include the header files MyCalendar.h and create a CMyCalendar object like in the example below:

#include "MyCalendar.h"

CMyCalendar calendar;
RECT wndRect = {100,100,0,0};
calendar.Create( hParentWnd, &wndRect );

The width and the height of the calendar window rectangle are not important since a calendar has fixed size. Next, set some calendar properties:

calendar.SetRange( 2000, 3000 ); // Sets calendar year range
calendar.SetDate( 15, 12, 1978 ); // Sets custom date
calendar.Expand(TRUE); // Expands calendar window

After the user changes date or expands/collapses calendar window, the CMyCalendar control sends the following messages via the WM_COMMAND message:

  • MC_DATECHANGED
  • MC_EXPANDED
  • MC_COLLAPSED

Some features of the CMyCalendar control:

  • Get current date
  • Set custom date
  • Get calendar year range
  • Set custom calendar year range (from year 1582 to year 4099)
  • Get current calendar background color
  • Set custom calendar background color
  • Expand/Collapse calendar window
  • Set on/off Sunday mark
  • Set on/off Today mark
  • Set on/off Easter mark
  • Get current calendar Easter calculation method
  • Set calendar Easter calculation method

Points of Interest

Working on this interesting Windows control, I have found much interesting things on calendars all over the Internet. I hope to extend the current control to support other types of calendars.

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

darkoman

Software Developer (Senior)
Elektromehanika d.o.o. Nis
Serbia Serbia

Member

He has a master degree in Computer Science at Faculty of Electronics in Nis (Serbia), and works as a C++/C# application developer for Windows platforms since 2001. He likes traveling, reading and meeting new people and cultures.

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. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMala pomoć :) PinmemberMember #395679210:30 26 Mar '07  
AnswerRe: Mala pomoć :) Pinmemberdarkoman19:32 26 Mar '07  
GeneralRe: Mala pomoć :) PinmemberTijana122:33 26 Mar '07  
AnswerRe: Mala pomoć :) Pinmemberdarkoman8:36 27 Mar '07  
Generalcharset selection PinmemberTomas Rapkauskas3:18 17 May '06  
GeneralMonths days PinmemberTomas Rapkauskas2:16 17 May '06  
GeneralRemember... Pinmemberchk9:05 15 Aug '05  
GeneralRe: Remember... Pinmemberdarkoman12:10 15 Aug '05  
GeneralBugs Pinmemberosy20:47 2 Aug '05  
GeneralRe: Bugs Pinmembermatrowang23:11 5 Jul '06  

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

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 8 Aug 2005
Article Copyright 2005 by darkoman
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid