MFC日历控件完全自绘MyCalendar Control
授权形式: 免费版 、绿色版
更新时间: 2016-11-23 08:57:35
软件语言: 简体中文
软件平台: WinXP,Win7,Win8,Win10
软件类别: 程序源码
文件大小: 57K
评论等级: ★★★★☆
浏览次数: (今日:,本周:,本月:

MFC日历控件完全自绘MyCalendar Control


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.


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:


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.