Click here to Skip to main content
15,892,480 members
Articles / Desktop Programming / ATL

VS File Finder

Rate me:
Please Sign up or sign in to vote.
4.90/5 (39 votes)
8 May 20053 min read 224.3K   3.3K   37  
A Visual Studio add-in to help navigate around large projects.
// ColourListCtrl.cpp : implementation file

#include "stdafx.h"
#include "ColourListCtrl.h"
#include "VSFileFinderCtrl.h"

ColourListCtrl::ColourListCtrl()
	: m_bHideText(false)
{
}

ColourListCtrl::~ColourListCtrl()
{
}

void ColourListCtrl::SetHideText(bool b)
{
	m_bHideText = b;
}

BEGIN_MESSAGE_MAP(ColourListCtrl, CListCtrl)
    ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw)
END_MESSAGE_MAP()

void ColourListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
    NMLVCUSTOMDRAW* pCustomDraw = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
    *pResult = OnCustomDraw(pCustomDraw);
}

LRESULT ColourListCtrl::OnCustomDraw(NMLVCUSTOMDRAW* pCustomDraw)
{
	DWORD dwStyle = GetStyle() & LVS_TYPEMASK;

    if (dwStyle == LVS_REPORT || dwStyle == LVS_LIST)
    {
        switch (pCustomDraw->nmcd.dwDrawStage)
        {
        case CDDS_PREPAINT:
            return CDRF_NOTIFYITEMDRAW;

        case CDDS_ITEMPREPAINT:
			{
				COLORREF c = GetItemColour(pCustomDraw);
				if (c == 0)
					return CDRF_DODEFAULT;
				if (m_bHideText)
					pCustomDraw->clrText = c;
				pCustomDraw->clrTextBk = c;
				return CDRF_NEWFONT;
			}
        }
    }

    return CDRF_DODEFAULT;
}

COLORREF ColourListCtrl::GetItemColour(NMLVCUSTOMDRAW* pCustomDraw) const
{
	return static_cast<COLORREF>(pCustomDraw->nmcd.lItemlParam);
}

FileFinderListCtrl::FileFinderListCtrl(const CVSFileFinderCtrl* pOwner)
	: m_pOwner(pOwner)
{
}

COLORREF FileFinderListCtrl::GetItemColour(NMLVCUSTOMDRAW* pCustomDraw) const
{
	return m_pOwner->GetColour(static_cast<int>(pCustomDraw->nmcd.dwItemSpec));
}

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


Written By
Web Developer
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