如何使用非默认颜色在MFC CListCtrl中绘制行/行文本 [英] How do I paint row/row text in MFC CListCtrl with non-default color

查看:70
本文介绍了如何使用非默认颜色在MFC CListCtrl中绘制行/行文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我继承了一些需要进行一些更改的旧MCF / C ++代码。 UI的大部分是CListCtrl,它以数据网格的方式显示一些实时数据。客户端希望我根据其中一列中的状态数据为某些颜色的某些行(或行文本)着色。虽然这个任务在Win Forms / WPF中非常简单,但在谷歌搜索后看起来并不是这样(请注意,我对MCF的经验很少......我可以找到代码的方法,但这几乎是所有)。



完成这样的事情最容易(最少侵入性)的方法......



<前lang =c ++> 开关(状态)
{
case 警告:
// 将行文本颜色设置为黄色
< span class =code-keyword> break ;
case 错误:
// 将行文本颜色设置为红色
break ;
案例有效:
// 将行文本颜色设置为绿色
break ;
默认
// 什么都不做......按原样保留颜色
break ;
}





状态是可随时更改的行值之一。



任何帮助都将不胜感激。

解决方案

我强烈怀疑你可能会发现关于CListCtrl自定义的任何文章...... [ ^ ]

I inherited some old MCF/C++ code that needs some changes. The bulk of the UI is CListCtrl that shows some real-time data in "data grid" fashion. The client wants me to colorize certain rows (or row texts) in certain colors according to status data in one of the columns. While this assignment would be pretty trivial in Win Forms/WPF it doesn't seem so in MFC after some googling (mind you, I have very little experience in MCF ... I can find my way around code, but that is pretty much all).

What would be the easiest (least invasive) way to accomplish something like this ...

switch (status)
{
   case warning:
      // set row text color to yellow
      break;
   case error:
      // set row text color to red
      break;
   case active:
      // set row text color to green
      break;
   default:
      // do nothing ... leave color as-is
      break;
}



The "status" is one of the row values that can change any time.

Any help would be appreciated.

解决方案

I strongly doubt you may find any article here on CListCtrl customization...[^].


这篇关于如何使用非默认颜色在MFC CListCtrl中绘制行/行文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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