When the control first starts to paint itself, in response to a WM_PAINT, you receive a NM_CUSTOMDRAW notification message, with the draw stage set to CDDS_PREPAINT. If you don’t handle this yourself that will be the end of it, as the default message handler will just tell the control to carry on with default drawing and not to interrupt you again.

If you do handle the message, you have a chance to do a bit of painting yourself if you want. You can then set a flag in the return result that says whether you want the control to do its default painting; you usually will. You can also set flags to say whether you want to receive further notifications. You can ask the control to send you a WM_CUSTOMDRAW notification for the CDDS_POSTPAINT draw stage when the control has finished drawing (you can then do some extra drawing yourself). You can also say that you want to get notifications for the CDDS_ITEMPREPAINT draw stage for each item drawn.

Similarly, when you get each WM_CUSTOMDRAW notification for the CDDS_ITEMPREPAINT draw stage, you can set up the colours to use, make changes to the device context including font changes, and maybe do some drawing yourself. You can then say whether you want the default painting for the item and whether you want to receive a CDDS_ITEMPOSTPAINT when the item drawing is finished.

If you are in report mode, you can also ask for individual notifications for each subitem. These have the draw stage set to (CDDS_ITEMPREPAINT | CDDS_SUBITEM), and again you can fiddle with the device context, do your own drawing and/or let the control do some drawing and optionally receive a (CDDS_ITEMPOSTPAINT | CDDS_SUBITEM) drawing stage message at the end of each subitem.

NOTE: subitem notifications are only available for custom controls V4.71 (that is, for IE4.0 or Windows 98) or later, so please ensure that you check the version of COMCTL32 you have on your machine if you intend to use custom draw controls.

NM_CUSTOMDRAW 消息的更多相关文章

  1. 针对NM_CUSTOMDRAW消息的学习

    消息的形式:1 窗口消息,2 命令消息,3 WM_NOTIFY消息,4 自定义消息 我们的NM_CUSTOMDRAW消息就是就属于第三种WM_NOTIFY消息,而添加消息映射的方法分为两种: BEGI ...

  2. MFC中ClistCtrl的=NM_CUSTOMDRAW消息

    =NM_CUSTOMDRAW是你点击列表内部是的消息映射: 例如:我想在我删除一行列表的数据,但是删除后下一行数据继续保持高亮状态 void CChildView::OnDel() { int cou ...

  3. mfc ui3

    引用:http://www.cnblogs.com/rainbowzc/archive/2010/06/02/1749872.html 本文专题讨论VC中的界面美化,适用于具有中等VC水平的读者.读者 ...

  4. (转)使用Custom Draw实现ListCtrl的重绘

    使用Custom Draw实现ListCtrl的重绘   common control 4.7版本介绍了一个新的特性叫做Custom Draw,这个名字显得模糊不清,让人有点摸不着头脑,而且MSDN里 ...

  5. 改变ListCtrl某行的背景色或者字体颜色

    大家也许熟悉WM_NOTIFY,控件通过WM_NOTIFY向父窗口发送消息.在WM_NOTIFY消息体中,部分控件会发送NM_CUSTOMDRAW告诉父窗口自己需要绘图. 也可以反射NM_CUSTOM ...

  6. ListControl常用操作汇总

    本文根据本人在项目中的应用,来谈谈CListCtrl的部分用法及技巧.当初学习时,查了很多资料,零零碎碎的作了些记录,现在主要是来做个总结,方便以后查阅.主要包括以下十三点内容:基本操作.获取选中行的 ...

  7. MFC窗口风格 WS_style/WS_EX_style(超详细)

    窗口风格(Window style) WS_BORDER   有边框窗口 WS_CAPTION   必须和WS_BORDER风格配合,但不能与WS_DLGFRAME风格一起使用.指示窗口包含标题要部分 ...

  8. 在 Visual C++ 中开发自定义的绘图控件

    本文讨论的重点介于两者 之间 — 公共控件赋予您想要的大部分功能,但控件的外观并不是您想要的.例如,列表视图控件提供在许多视图风格中显示数据列表的方式 — 小图标.大图标.列表和详细列表(报告).然而 ...

  9. VC之美化界面(内容覆盖十分全面,经典)

    界面美化 摘要本文专题讨论VC中的界面美化,适用于具有中等VC水平的读者.读者最好具有以下VC基础: 1. 大致了解MFC框架的基本运作原理: 2. 熟悉Windows消息机制,熟悉MFC的消息映射和 ...

随机推荐

  1. 从零搭建LNMP环境

    Linux就是环境所在的操作系统: Nginx则是一个「高性能的HTTP和反向代理服务器」,官网地址:http://nginx.org/: MySQL则是一个方便地对数据进行增删改查的数据库管理系统, ...

  2. POJ 1861 Network (模版kruskal算法)

    Network Time Limit: 1000MS Memory Limit: 30000K Total Submissions: Accepted: Special Judge Descripti ...

  3. django-debug-toolbar

    一:安装django-debug-toolbar. 二:在settings里的MIDDLEWARE_CLASSES加入'debug_toolbar.middleware.DebugToolbarMid ...

  4. 浏览器hack总结 详细的浏览器兼容性解决方法

    由于各浏览器对页面的解析不同,会导致页面在不同浏览器中显示的样式不一致,为了保持页面的统一,经常需要对浏览器进行兼容性问题的调试. CSS Hack 面对浏览器诸多的兼容性问题,经常需要通过CSS样式 ...

  5. 凡客副总裁被曝离职:或因IPO受阻|凡客|王春焕|离职_互联网_新浪科技_新浪网

    凡客副总裁被曝离职:或因IPO受阻|凡客|王春焕|离职_互联网_新浪科技_新浪网 凡客副总裁被曝离职:或因IPO受阻 2013年05月07日 00:56   每日经济新闻    我有话说     每经 ...

  6. eclipse中build workspace的相关优化

    网上流传的各种的eclipse的调优的方法都大同小异,但是调优的基本上针对eclipse或者myclipse的本身,比如关掉validate和启动项,文件拼写,和自动构建等,调过之后,等个eclips ...

  7. asp.net core 使用 Redis 和 Protobuf

    asp.net core 使用 Redis 和 Protobuf 前言 上篇博文介绍了怎么样在 asp.net core 中使用中间件,以及如何自定义中间件.项目中刚好也用到了Redis,所以本篇就介 ...

  8. img src某个php文件输出图片(回复更改图片readfile读取图片等)

    在论坛我们经常看到一回复图片就更改等,这功能是怎么实现的呢,其实更验证码道理相同. 新建文件 randimage.php 加入以下代码: <?php $dir='../../images/'; ...

  9. SPOJ 11840. Sum of Squares with Segment Tree (线段树,区间更新)

    http://www.spoj.com/problems/SEGSQRSS/ SPOJ Problem Set (classical) 11840. Sum of Squares with Segme ...

  10. asp.net错误.在应用程序级别之外使用注册为 allowDefinition='MachineToApplication' 的节是错

    解决办法:将该项目所在目录设置为虚拟目录,右键-转为应用程序.