Click here to Skip to main content
15,893,588 members
Articles / Desktop Programming / MFC

An MFC-CListCtrl derived class that allows other ‘controls’ to be inserted into a particular cell

Rate me:
Please Sign up or sign in to vote.
4.92/5 (54 votes)
5 Jan 2014CPOL12 min read 168.1K   14K   160  
A class derived from CListCtrl that allows edit controls, combo boxes, check boxes, date pickers, and color pickers to be inserted into or removed from particular cells extremely easily. The inserted 'controls' are not CWnd-derived.
//
// MCCtrl.cpp : implementation file
//

#include "stdafx.h"
#include "MCCtrl.h"
#include "popupcalendar.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMCCtrl

CMCCtrl::CMCCtrl() : m_pPopupCalendar(NULL)
{
}

CMCCtrl::~CMCCtrl()
{
}


BEGIN_MESSAGE_MAP(CMCCtrl, CMonthCalCtrl)
	//{{AFX_MSG_MAP(CMCCtrl)
	ON_NOTIFY_REFLECT(MCN_SELECT, OnSelect)
	ON_NOTIFY_REFLECT(MCN_SELCHANGE, OnSelchange)
	ON_WM_KEYDOWN()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMCCtrl message handlers

void CMCCtrl::OnSelect(NMHDR* pNMHDR, LRESULT* pResult) 
{
	if (m_pPopupCalendar)
		m_pPopupCalendar->OnMCSelect(pNMHDR, pResult);

	*pResult = 0;
}

void CMCCtrl::OnSelchange(NMHDR* pNMHDR, LRESULT* pResult) 
{
	if (m_pPopupCalendar)
		m_pPopupCalendar->OnMCSelchange(pNMHDR, pResult);

	*pResult = 0;
}

void CMCCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
	if (nChar == VK_F4)
		m_pPopupCalendar->OnKeyDown(nChar, nRepCnt, nFlags);
	else
		CMonthCalCtrl::OnKeyDown(nChar, nRepCnt, nFlags);
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions