Click here to Skip to main content
12,764,177 members (37,888 online)
Click here to Skip to main content

Stats

130.8K views
3.2K downloads
61 bookmarked
Posted 25 Feb 2004

A reminder tool for .dan.g's ToDoList

, 25 Feb 2004
A simple reminder tool to remind you of your overdue tasks in ToDoList throughout the day
// TasksListCtrl.cpp : implementation file
//

#include "stdafx.h"
#include "TDLReminderTool.h"
#include "TasksListCtrl.h"

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

/////////////////////////////////////////////////////////////////////////////
// CTasksListCtrl

CTasksListCtrl::CTasksListCtrl()
{

}

CTasksListCtrl::~CTasksListCtrl()
{
	ClearItemData();
}


BEGIN_MESSAGE_MAP(CTasksListCtrl, CListCtrl)
	//{{AFX_MSG_MAP(CTasksListCtrl)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
	ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomdrawList)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTasksListCtrl message handlers

void CTasksListCtrl::OnCustomdrawList ( NMHDR* pNMHDR, LRESULT* pResult )
{
	NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );

    // Take the default processing unless we set this to something else below.
    *pResult = 0;

    // First thing - check the draw stage. If it's the control's prepaint
    // stage, then tell Windows we want messages for every item.

    if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
    {
		*pResult = CDRF_NOTIFYITEMDRAW;
    }
    else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
    {
        // This is the notification message for an item.  We'll request
        // notifications before each subitem's prepaint stage.

		*pResult = CDRF_NOTIFYSUBITEMDRAW;
    }
    else if ( (CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage )
    {
        // This is the prepaint stage for a subitem. Here's where we set the
        // item's text and background colors. Our return value will tell 
        // Windows to draw the subitem itself, but it will use the new colors
        // we set here.
        // The text color will cycle through red, green, and light blue.
        // The background color will be light blue for column 0, red for
        // column 1, and black for column 2.
    
			COLORREF crText = RGB(0,0,0);//pLVCD->nmcd.lItemlParam;
			COLORREF crBkgnd = RGB(255,255,255);
			
	/*        if ( 0 == pLVCD->iSubItem )
				{
				crText = RGB(255,0,0);
				crBkgnd = RGB(128,128,255);
				}
			else if ( 1 == pLVCD->iSubItem )
				{
				crText = RGB(0,255,0);
				crBkgnd = RGB(255,0,0);
				}
			else
				{
				crText = RGB(128,128,255);
				crBkgnd = RGB(0,0,0);
				}
	*/
			
			
    }
}


int CALLBACK SortAscFunc(LPARAM lParam1, LPARAM lParam2, LPARAM lParamSort)
{
	int nRetVal = 0;

	PITEMDATA pData1 = (PITEMDATA)lParam1;
	PITEMDATA pData2 = (PITEMDATA)lParam2;


	switch(lParamSort)
	{
		case 0:	// Due Date
		{
			nRetVal = strcmp(pData1->pszDueDate,pData2->pszDueDate);
			break;
		}
		case 1:	// Title
		{
			nRetVal = strcmp(pData1->pszTaskTitle,pData2->pszTaskTitle);
			break;
		}
	}

	return nRetVal;
} 

void CTasksListCtrl::addItemData(ITEMDATA* pData)
{
	m_ItemDataArr.push_back(pData);
}

void CTasksListCtrl::ClearItemData()
{
	ITEMDATA* pData = NULL;
	for(int i=0; i<m_ItemDataArr.size();++i)
	{
		pData = m_ItemDataArr[i];

		delete pData;
		pData = NULL;
	}
	m_ItemDataArr.clear();
}

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 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

Alberto Bar-Noy
Team Leader www.unitronics.com
Israel Israel
No Biography provided

You may also be interested in...

Pro
Pro
Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170217.1 | Last Updated 26 Feb 2004
Article Copyright 2004 by Alberto Bar-Noy
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid