Click here to Skip to main content
Click here to Skip to main content
Go to top

CoolCalendar a perpetual calendar control

, 14 Feb 2001
Rate this:
Please Sign up or sign in to vote.
An ownderdrawn perpetual calendar control
  • Download Perpetual Calendar Project 44 Kb
  • Background

    During my career I have designed numerous user interfaces and widgets. I have yet to see a calendar that has a perpetual or rolling feature built in. By this I mean to change the month by selecting on the previous or next months days, rather that moving from the calendar interface to the month combobox. Well hopefully this calendar overcomes some of the shortfalls most calendar controls have on the market.

    Features

    • Spinner control (optional) to scroll 7 days at a time.
    • Perpetual or rolling functionality allows user to click on previous and next month.
    • Programmatically attach a note to day
    • Fulfills UI guidelines
    • Date select notification

    Interface

    COleDateTime GetDate() Gets the currently selected date
    void ShowSpinner(BOOL bShow); Shows or hides the month spinner
    BOOL SetDate(COleDateTime tm); Sets the current date
    BOOL AddNote(COleDateTime& date, CString strNote, BOOL bReplace); Attaches a note to a date
    void DeleteNote(COleDateTime& date); Deletes a note from a date
    void ClearAllNotes(); Removes all notes

    Implemention

    Files:

    • CalWnd.h & CalWnd.cpp (Main calendar functionality)
    • CalBtn.h & CalBtn.cpp (Calendar button objects)
    • Popup.h & Popup.cpp (Popup Context menu)
    • NoEdit.h & NoEdit.cpp (Disabled edit box)

    In your windows header file that's going host the control, include "calwnd.h"

    // Include calendar and dependency files
    #include "CalWnd.h"
    

    Now make a CCalWnd object a member of your hosting window class

    class CMyWnd
    {
    public:
    ... Some other stuff
    protected:
        CCalWnd	m_wndCalendar;  
    
    

    Now create the calendar window, usually done when the hosting window is created.

    int CChildView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
    {	
    	// Call base class implementation of OnCreate first
    	if (CWnd ::OnCreate(lpCreateStruct) == -1)
    		return -1;
    	
    
    	// Now create our calendar control
    	// This creates the window at the left, top position.
    	// The calendar automatically sizes...
    	if (m_wndCalendar.Create(NULL,"Calendar",
    	                         WS_VISIBLE|WS_CHILD,
    	                         CRect(20,20,0,0),this,0x0101) == -1)
    		return -1;
    	... Some other code
    

    Now we need to implement a handler for the date change notification. (When the user clicks on a date). This is inserted your hosting windows .cpp file. Put this outside of the AFX_MSG_MAP comments.

    BEGIN_MESSAGE_MAP(CChildView,CWnd )
    	//{{AFX_MSG_MAP(CChildView)
    	ON_WM_PAINT()
    	ON_WM_CREATE()
    	ON_WM_LBUTTONDBLCLK()
    	//}}AFX_MSG_MAP
    	ON_MESSAGE(WM_DATE_NOTIFY,OnDateNotify) // <--- HERE
    END_MESSAGE_MAP()

    This is inserted your hosting windows .h file. Put this outside of the AFX_MSG_MAP comments.

    //{{AFX_MSG(CChildView)
    	afx_msg void OnPaint();
    	afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
    	afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
    	//}}AFX_MSG
    	afx_msg LRESULT OnDateNotify(WPARAM wParam, LPARAM nId); // <--- HERE
    	DECLARE_MESSAGE_MAP()
    

    On finally the handler itself.

    LRESULT CChildView::OnDateNotify(WPARAM wParam, LPARAM nControlId)
    {
    	COleDateTime tm = m_wndCalendar.GetDate();
    
    	TRACE("Date Selected %s for Control ID %d\n",tm.Format("%c"), nControlId);
    	return 0;
    }

    See the example for further use of the calendar. Please contact me if you find bugs, or you would like to see further functionality.

    Happy coding... Smile | :)

    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

    NormDroid
    Software Developer (Senior) Software Kinetics
    United Kingdom United Kingdom



    Software Kinetics
    are experts in developing customised and bespoke applications and have expertise in the development of desktop, mobile and internet applications on Windows.

    We specialise in:

    • User Interface Design
    • Desktop Development
    • Windows Phone Development
    • Windows Presentation Framework
    • Windows Forms
    • Windows Communication Framework
    • Windows Services
    • Network Applications
    • Database Applications
    • Web Development
    • Web Services
    • Silverlight
    • ASP.net
     
    Visit Software Kinetics
    Follow on   Twitter

    Comments and Discussions

     
    GeneralMy vote of 1 PinmemberSheetal_Joshi8-Dec-09 6:08 
    QuestionHow Can I do PinsussAnonymous12-May-03 23:20 
    GeneralAnother Problem with TTS_BALLOON PinmemberJoseph Dempsey15-Feb-01 12:02 
    GeneralRe: Another Problem with TTS_BALLOON PinmemberUwe Keim15-Feb-01 20:48 
    GeneralRe: Another Problem with TTS_BALLOON PinmemberJoseph Dempsey16-Feb-01 6:38 
    GeneralRe: Another Problem with TTS_BALLOON PinmemberNorm Almond16-Feb-01 8:13 
    GeneralRe: Another Problem with TTS_BALLOON PinmemberAnonymous14-Oct-01 19:42 
    GeneralRe: Another Problem with TTS_BALLOON Pinmemberpa19685-Jun-06 23:59 
    GeneralFix the author's homepage URL PinmemberAmmar10-Dec-00 20:52 
    GeneralRe: Fix the author's homepage URL PinmemberErik Thompson11-Dec-00 4:46 
    GeneralProblems PinmemberMatt Philmon10-Dec-00 13:44 
    GeneralRe: Problems PinmemberNorm Almond10-Dec-00 22:17 
    GeneralRe: Problems fix? PinmemberDavid Scambler11-Dec-00 12:26 
    GeneralRe: Problems fix? PinmemberNorm Almond11-Dec-00 21:44 
    GeneralRe: Problems fix? PinmemberDavid Scambler12-Dec-00 11:25 
    GeneralRe: Problems fix? PinmemberNorm Almond12-Dec-00 23:33 
    GeneralRe: Problems fix? Pinmemberarbrsoft22-Dec-03 5:22 

    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.

    | Advertise | Privacy | Mobile
    Web01 | 2.8.140916.1 | Last Updated 15 Feb 2001
    Article Copyright 2001 by NormDroid
    Everything else Copyright © CodeProject, 1999-2014
    Terms of Service
    Layout: fixed | fluid