Click here to Skip to main content
12,503,838 members (33,023 online)
Click here to Skip to main content
Add your own
alternative version

Stats

114.6K views
1.6K downloads
23 bookmarked
Posted

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... :)

    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

    You may also be interested in...

    Pro
    Pro

    Comments and Discussions

     
    GeneralMy vote of 1 Pin
    Sheetal_Joshi8-Dec-09 6:08
    memberSheetal_Joshi8-Dec-09 6:08 
    QuestionHow Can I do Pin
    Anonymous12-May-03 23:20
    sussAnonymous12-May-03 23:20 
    GeneralAnother Problem with TTS_BALLOON Pin
    Joseph Dempsey15-Feb-01 12:02
    memberJoseph Dempsey15-Feb-01 12:02 
    GeneralRe: Another Problem with TTS_BALLOON Pin
    Uwe Keim15-Feb-01 20:48
    memberUwe Keim15-Feb-01 20:48 
    GeneralRe: Another Problem with TTS_BALLOON Pin
    Joseph Dempsey16-Feb-01 6:38
    memberJoseph Dempsey16-Feb-01 6:38 
    GeneralRe: Another Problem with TTS_BALLOON Pin
    Norm Almond16-Feb-01 8:13
    memberNorm Almond16-Feb-01 8:13 
    GeneralRe: Another Problem with TTS_BALLOON Pin
    Anonymous14-Oct-01 19:42
    memberAnonymous14-Oct-01 19:42 
    GeneralRe: Another Problem with TTS_BALLOON Pin
    pa19685-Jun-06 23:59
    memberpa19685-Jun-06 23:59 
    GeneralFix the author's homepage URL Pin
    Ammar10-Dec-00 20:52
    memberAmmar10-Dec-00 20:52 
    GeneralRe: Fix the author's homepage URL Pin
    Erik Thompson11-Dec-00 4:46
    memberErik Thompson11-Dec-00 4:46 
    GeneralProblems Pin
    Matt Philmon10-Dec-00 13:44
    memberMatt Philmon10-Dec-00 13:44 
    GeneralRe: Problems Pin
    Norm Almond10-Dec-00 22:17
    memberNorm Almond10-Dec-00 22:17 
    GeneralRe: Problems fix? Pin
    David Scambler11-Dec-00 12:26
    memberDavid Scambler11-Dec-00 12:26 
    GeneralRe: Problems fix? Pin
    Norm Almond11-Dec-00 21:44
    memberNorm Almond11-Dec-00 21:44 
    GeneralRe: Problems fix? Pin
    David Scambler12-Dec-00 11:25
    memberDavid Scambler12-Dec-00 11:25 
    GeneralRe: Problems fix? Pin
    Norm Almond12-Dec-00 23:33
    memberNorm Almond12-Dec-00 23:33 
    GeneralRe: Problems fix? Pin
    arbrsoft22-Dec-03 5:22
    memberarbrsoft22-Dec-03 5:22 

    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
    Web02 | 2.8.160919.1 | Last Updated 15 Feb 2001
    Article Copyright 2001 by NormDroid
    Everything else Copyright © CodeProject, 1999-2016
    Layout: fixed | fluid