mylistctrl.cpp

来自「Visual_C++[1].NET_Bible1 Visual_C++宝典书中」· C++ 代码 · 共 65 行

CPP
65
字号
// MyListCtrl.cpp : implementation file
//

#include "stdafx.h"
#include "ListCtrlColor.h"
#include "MyListCtrl.h"

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

/////////////////////////////////////////////////////////////////////////////
// CMyListCtrl

CMyListCtrl::CMyListCtrl()
{
}

CMyListCtrl::~CMyListCtrl()
{
}

bool CMyListCtrl::IsDraw() {
	return true;
}
bool CMyListCtrl::OnDraw(CDC* pDC) {
	CRect r;
	GetClientRect(r);
	CBrush brush(RGB(0,255,255));	// cyan
	pDC->FillRect(r,&brush);
	return false; // do default drawing as well
}

bool CMyListCtrl::IsNotifyItemDraw() {
	return true;
}
bool CMyListCtrl::IsNotifySubItemDraw(int /*nItem*/, UINT /*nState*/, LPARAM /*lParam*/) {
	return true;
}
COLORREF CMyListCtrl::TextColorForSubItem(int nItem, int nSubItem, UINT /*nState*/, LPARAM /*lParam*/) {
	if (0 == (nItem+nSubItem)%2) {
		return RGB(255,255,0);	// yellow
	} else {
		return CLR_DEFAULT;
	}
}
COLORREF CMyListCtrl::BkColorForSubItem(int nItem, int nSubItem, UINT /*nState*/, LPARAM /*lParam*/) {
	if (0 == (nItem+nSubItem)%2) {
		return RGB(255,0,255);	// magenta
	} else {
		return CLR_DEFAULT;
	}
}

BEGIN_MESSAGE_MAP(CMyListCtrl, CListCtrlWithCustomDraw)
	//{{AFX_MSG_MAP(CMyListCtrl)
		// NOTE - the ClassWizard will add and remove mapping macros here.
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMyListCtrl message handlers

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?