CtrlList每行不同颜色
来源:互联网 发布:程序侠淘宝客程序源码 编辑:程序博客网 时间:2024/04/27 07:45
//消息映射中添加
ON_NOTIFY(NM_CUSTOMDRAW,IDC_LIST_DATA,OnCustomdrawListCtrl)
//头文件添加
afx_msg void OnCustomdrawListCtrl(NMHDR *pNMHDR, LRESULT *pResult);
/************************************************************************/
/* CtrlList每行不同颜色
/************************************************************************/
void CDbMiddleSrvDlg::OnCustomdrawListCtrl(NMHDR *pNMHDR, LRESULT *pResult)
{
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
// Take the default processing unless we set this to something else below.
*pResult = CDRF_DODEFAULT;
m_ctrlListCtrlData.SetExtendedStyle(m_ctrlListCtrlData.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
//
// First thing - check the draw stage. If it's the control's prepaint
// stage, then tell Windows we want messages for every item.
//m_ctrlListCtrlData.SetBkColor(RGB(0,0,0));
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 )
{
COLORREF clrNewTextColor, clrNewBkColor;
int nItem = static_cast<int>( pLVCD->nmcd.dwItemSpec );
CString strTemp = m_ctrlListCtrlData.GetItemText(nItem,2/*pLVCD->iSubItem*/);
if("ÔËÐÐ"==strTemp)
{
clrNewTextColor = RGB(0,255,0); //Set the text to red
clrNewBkColor = RGB(0,0,0); //Set the bkgrnd color to blue
}
else
{
clrNewTextColor = RGB(255,0,0); //Leave the text black
clrNewBkColor = RGB(0,0,0); //leave the bkgrnd color white
}
pLVCD->clrText = clrNewTextColor;
pLVCD->clrTextBk = clrNewBkColor;
//m_ctrlListCtrlData.Invalidate();
// Tell Windows to paint the control itself.
*pResult = CDRF_DODEFAULT;
}
m_ctrlListCtrlData.UpdateWindow();
}
ON_NOTIFY(NM_CUSTOMDRAW,IDC_LIST_DATA,OnCustomdrawListCtrl)
//头文件添加
afx_msg void OnCustomdrawListCtrl(NMHDR *pNMHDR, LRESULT *pResult);
/************************************************************************/
/* CtrlList每行不同颜色
/************************************************************************/
void CDbMiddleSrvDlg::OnCustomdrawListCtrl(NMHDR *pNMHDR, LRESULT *pResult)
{
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
// Take the default processing unless we set this to something else below.
*pResult = CDRF_DODEFAULT;
m_ctrlListCtrlData.SetExtendedStyle(m_ctrlListCtrlData.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
//
// First thing - check the draw stage. If it's the control's prepaint
// stage, then tell Windows we want messages for every item.
//m_ctrlListCtrlData.SetBkColor(RGB(0,0,0));
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 )
{
COLORREF clrNewTextColor, clrNewBkColor;
int nItem = static_cast<int>( pLVCD->nmcd.dwItemSpec );
CString strTemp = m_ctrlListCtrlData.GetItemText(nItem,2/*pLVCD->iSubItem*/);
if("ÔËÐÐ"==strTemp)
{
clrNewTextColor = RGB(0,255,0); //Set the text to red
clrNewBkColor = RGB(0,0,0); //Set the bkgrnd color to blue
}
else
{
clrNewTextColor = RGB(255,0,0); //Leave the text black
clrNewBkColor = RGB(0,0,0); //leave the bkgrnd color white
}
pLVCD->clrText = clrNewTextColor;
pLVCD->clrTextBk = clrNewBkColor;
//m_ctrlListCtrlData.Invalidate();
// Tell Windows to paint the control itself.
*pResult = CDRF_DODEFAULT;
}
m_ctrlListCtrlData.UpdateWindow();
}
- CtrlList每行不同颜色
- CtrlList使用方法
- CTRLLIST用法
- MFC类CtrlList使用方法
- MFC类CtrlList使用方法
- CtrlList判断点击的是否为CheckBox
- 如何在ctrllist控件上改变制定的颜色?
- 初始化ctrlList控件(字体和行高)
- 隔行颜色设置及其设置特定行颜色(ctrlList)
- 文字不同颜色闪烁
- datalist隔行不同颜色
- 定制Row的不同颜色
- 表格不同颜色的循环
- struts2-隔行显示不同颜色
- 显示不同颜色的LIST
- CSS 隔行显示不同颜色
- Linux打印不同颜色字符串
- Linux输入不同颜色字体
- Linux系统启动类故障排除(实验篇)-单学武
- scp
- C#接口-接口作用
- 动态连接3-readelf -S -s file_b.so
- BASIS - Display area menu setting
- CtrlList每行不同颜色
- P2P 之 UDP穿透NAT的原理与实现(附源代码)
- 基于slackware的发行版小结
- HTTP 错误 500.19 Internal Server Error的解决方法
- 动态连接4-readelf -S -s hello
- Dalvik--Android专属Java虚拟机
- 拖曳js
- Java学习系列之---集合包
- Nginx和Tomcat负载均衡实现session共享