博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CListCtrl列表中,改写几列的文字颜色
阅读量:5731 次
发布时间:2019-06-18

本文共 2464 字,大约阅读时间需要 8 分钟。

1 void CMyDlg::OnCustomdrawMyList ( NMHDR* pNMHDR, LRESULT* pResult ) 2 { 3   NMLVCUSTOMDRAW* pLVCD = reinterpret_cast
( pNMHDR ); // Take the default processing unless we set this to something else below. 4 *pResult = CDRF_DODEFAULT; // First thing - check the draw stage. If it's the control's prepaint 5 // stage, then tell Windows we want messages for every item. 6 if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage ) 7 { 8 *pResult = CDRF_NOTIFYITEMDRAW; 9 } 10 elseif ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage ) 11 {12 // This is the notification message for an item. We'll request 13 // notifications before each subitem's prepaint stage. 14 *pResult = CDRF_NOTIFYSUBITEMDRAW; 15 } 16 elseif ( (CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage ) 17 {18 // This is the prepaint stage for a subitem. Here's where we set the 19 // item's text and background colors. Our return value will tell 20 // Windows to draw the subitem itself, but it will use the new colors 21 // we set here. 22 // The text color will cycle through red, green, and light blue. 23 // The background color will be light blue for column 0, red for 24 // column 1, and black for column 2. 25 26 COLORREF crText, crBkgnd; 27 if ( 0 == pLVCD->iSubItem )28 { 29 crText = RGB(255,0,0); 30 crBkgnd = RGB(128,128,255); 31 } 32 elseif ( 1 == pLVCD->iSubItem ) 33 { 34 crText = RGB(0,255,0); 35 crBkgnd = RGB(255,0,0); 36 } 37 else 38 { 39 crText = RGB(128,128,255); 40 crBkgnd = RGB(0,0,0); 41 } 42 // Store the colors back in the NMLVCUSTOMDRAW struct. 43 44 pLVCD->clrText = crText; 45 pLVCD->clrTextBk = crBkgnd; 46 47 // Tell Windows to paint the control itself. 48 *pResult = CDRF_DODEFAULT; 49 }50 }
View Code

 

转载于:https://www.cnblogs.com/cwbo-win/articles/3393880.html

你可能感兴趣的文章
Memcache存储大数据的问题
查看>>
HTML5区域范围文本框实例页面
查看>>
oracle查看经常使用的系统信息
查看>>
技术工坊|如何利用ERC875协议开发世界杯区块链门票?(北京)
查看>>
Django_4_视图
查看>>
Linux的netstat命令使用
查看>>
shell实例100例《五》
查看>>
lvm讲解,磁盘故障小案例
查看>>
24.5 saltstack远程执行命令
查看>>
配置IP
查看>>
大快网站:如何选择正确的hadoop版本
查看>>
经过这5大阶段,你离Java程序员就不远了!
查看>>
Nginx配置文件相关操作
查看>>
IntelliJ IDEA 连接数据库详细过程
查看>>
thymeleaf 学习笔记-基础篇
查看>>
分享话题列表
查看>>
PHP-X开发扩展
查看>>
android学习笔记——onSaveInstanceState的使用
查看>>
Windows Server 2003下cwRsyncServer服务端与cwRsync客户端数据
查看>>
iOS 打包上传没有用到日历,但是提示需要在info.plist文件中加入NSCalendarsUsageDescription...
查看>>