着色列表控件 [英] Coloring list control

查看:51
本文介绍了着色列表控件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在mfc中使用列表控件。请帮助改变视图记录列表控件的颜色?<



我尝试过:



i试图改变列表控件的颜色。但是外部颜色只是改变了。

 BOOL Tag :: OnEraseBkgnd(CDC * pDC)
{
CRect r;
GetClientRect(& r);
CBrush br(RGB( 0 100 0 ));
pDC-> SelectObject(br);
pDC-> FillRect(r,& br);
return TRUE;
}

HBRUSH Tag :: OnCtlColor(CDC * pDC,CWnd * pWnd,UINT nCtlColor)
{
CBrush br(RGB( 0 255 0 ));
return (HBRUSH)br;
}

解决方案

要设置所有项目的颜色,请使用 SetTextColor SetBkColor SetTextBkColor [/编辑]。



如果要设置单个项目的颜色,则必须处理 NM_CUSTOMDRAW 通知:利用自定义绘制在列表控件中做的整洁的东西 [ ^ ]

iam using list control in mfc . pls help to change the color of list control of view record?<

What I have tried:

i tried to change the color of the list control.but the outside color only changed.

BOOL Tag::OnEraseBkgnd(CDC* pDC)
{
	CRect r;
	GetClientRect(&r);
	CBrush br(RGB(0, 100, 0));
	pDC->SelectObject(br);
	pDC->FillRect(r, &br);
	return TRUE;
}

HBRUSH Tag::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
	CBrush br(RGB(0, 255, 0));
	return (HBRUSH)br;
}

解决方案

To set the color for all items use SetTextColor and SetBkColor [EDIT], and SetTextBkColor[/EDIT].

If you want to set the colour for individual items, you have to handle the NM_CUSTOMDRAW notification: Neat Stuff to Do in List Controls Using Custom Draw[^]


这篇关于着色列表控件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆