Click here to Skip to main content
12,404,478 members (70,803 online)
Click here to Skip to main content
Add your own
alternative version

Stats

102.8K views
2.8K downloads
44 bookmarked
Posted

An MS Outlook-style mini-calendar control using WTL

, 5 Jun 2003
Rate this:
Please Sign up or sign in to vote.
An MS Outlook-style mini-calendar control using WTL

Sample Image

Introduction

This article explains an MS Outlook-style mini-calendar control using WTL.

This began as a port of Matt Gullett's MS Outlook-style miniature calendar control written for MFC. There are still some features remaining to be added to it, but it serves as a reasonable starting point for anyone needing this functionality in a WTL application.

Features

  • Display months in n-columns by m-rows
  • Single-date or date-range selection (including SHIFT-extended selection)
  • Different fonts for: header, day initials, and day numbers
  • Auto-repeat on scroll arrows
  • Auto-scroll when previous/following months' days are selected
  • Callback (via WM_NOTIFY) for highlighting 'special days'
  • Month-year selection from header popup (with drop shadow under XP)

Optional display styles include:

  • 3D border
  • Today's date highlighted
  • Previous/following months' days displayed with the months' days
  • Week can start on any day of the week

Environment

This control was developed using VC++ .NET, WTL 7, and the Feb 2003 Platform SDK. It has been tested under Windows XP only.

History

  • 22 May 2003
    • Initial release
  • 6 June 2003
    • Added month/year selection popup
    • Added 'special date' highlighting
  • Soon...?
    • Buttons (optional) for selecting today's date, and for clearing the selection
    • Provide internationalisation support
    • Make it an ActiveX component

Acknowledgements

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

Share

About the Author

Tony Ioanides
Web Developer
Australia Australia
No Biography provided

You may also be interested in...

Comments and Discussions

 
GeneralUse this C++ in VB project Pin
Blackboss9-May-06 1:43
memberBlackboss9-May-06 1:43 
Generalcompile error Pin
humbird27-Jun-05 0:06
memberhumbird27-Jun-05 0:06 
GeneralBug in SetRange(...) Pin
vschoech4-Jul-04 23:48
membervschoech4-Jul-04 23:48 
GeneralRe: Bug in SetRange(...) Pin
Tony Ioanides5-Jul-04 11:58
memberTony Ioanides5-Jul-04 11:58 
GeneralRe: Bug in SetRange(...) Pin
vschoech5-Jul-04 22:40
membervschoech5-Jul-04 22:40 
GeneralForcing NotifyGetSpecialDays() Pin
vschoech13-Jan-04 0:31
membervschoech13-Jan-04 0:31 
GeneralRe: Forcing NotifyGetSpecialDays() Pin
Tony Ioanides14-Jan-04 21:54
memberTony Ioanides14-Jan-04 21:54 
QuestionBug ResetRange()/NotifySelChanged()? Pin
vschoech13-Jan-04 0:23
membervschoech13-Jan-04 0:23 
AnswerRe: Bug ResetRange()/NotifySelChanged()? Pin
Tony Ioanides14-Jan-04 22:21
memberTony Ioanides14-Jan-04 22:21 
GeneralRe: Bug ResetRange()/NotifySelChanged()? Pin
vschoech14-Jan-04 23:07
membervschoech14-Jan-04 23:07 
Tony, it is nice to see that you are still interested in your own code. Smile | :)

While you are at it, preparing an update: I have another question/suggestion regarding CMiniCalendarCtrl::ResetRange(). What is the intended semantics of this method? From the name I would infer that a call to ResetRange actually resets the Ctrl to its pre-user-interaction state. But this is not the case, even after calling ResetRange() there is still a selection visible in the Ctrl.

To achieve clearance of the entire selection, I extended the method as follows:
BOOL
CMiniCalendarCtrl::ResetRange()
{
	if (m_dtAnchor.GetStatus() == COleDateTime::valid)
	{
		m_dtAnchor.SetStatus(COleDateTime::invalid);
		m_dtSelect.SetStatus(COleDateTime::invalid);
		NotifySelChanged();
 
		Invalidate();
		return TRUE;
	}
	
	m_dtAnchor.SetStatus(COleDateTime::invalid);
	m_dtSelect.SetStatus(COleDateTime::invalid);
	return FALSE;
}

If this is not what ResetRange() was meant to do, then what is it? ResetRange() is called twice from inside your own code, in CMiniCalendarCtrl::OnLButtonDown(UINT nFlags, CPoint point) and in CMiniCalendarCtrl::ApplyStyle(DWORD dwStyle). I'm not sure if my changes are consistent with your use of the method in these places. Some quick testing suggests that they are.

Moreover, I added another public method that allows to prepare the range with some default selection before the user is displayed the Ctrl (or even change selection on the fly):

void
CMiniCalendarCtrl::SetRange(const COleDateTime& dateAnchor, const COleDateTime& dateSelect)
{
	ATLASSERT( dateAnchor.GetStatus()==COleDateTime::valid );	
	ATLASSERT( dateSelect.GetStatus()==COleDateTime::valid );	
	m_dtAnchor = dateAnchor;
	m_dtSelect = dateSelect;
	NotifySelChanged();
	Invalidate();
}

Just for review or as a suggestion...
Thanks a lot!
Volker
GeneralGood work. Pin
Matt Gullett6-Jun-03 23:51
memberMatt Gullett6-Jun-03 23:51 
GeneralWow this is just what I have been doing the last few weeks! Pin
Angus Comber4-Jun-03 12:43
memberAngus Comber4-Jun-03 12:43 
General10 Pin
Hans J. Schroeder26-May-03 10:41
memberHans J. Schroeder26-May-03 10:41 
GeneralNICE Pin
SledgeHammer21-May-03 22:44
memberSledgeHammer21-May-03 22:44 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.160721.1 | Last Updated 6 Jun 2003
Article Copyright 2003 by Tony Ioanides
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid