- 浏览: 697806 次
- 性别:
- 来自: 西安
-
文章分类
- 全部博客 (440)
- c++学习笔记 (89)
- 如何适应变化 (1)
- VC常见问题 (7)
- Brew开发12月9日至12月26日 (1)
- 软件架构 (3)
- 自己动手写C语言编译器之文档翻译工作 (1)
- 自己动手写C语言编译器 (6)
- 网站资源 (1)
- 郝彬英文教程 (1)
- 45度斜角地图 (0)
- 35.264等角视图 (0)
- 30等角视图 (1)
- 如何搞opengl (1)
- 卷积。 (1)
- Android解析日记 (5)
- Linux基础教学 (9)
- Android游戏框架 (9)
- Android游戏开发之OpenGL之坐标矩阵 (2)
- Android异常处理 (1)
- 资源网站 (1)
- ARM汇编学习 (1)
- game (0)
- 自己动手实现OpenGL(准备开始!后面有空补充) (3)
- 云计算 (1)
- Android面试题目 (17)
- 深度学习 (1)
- OpenGL实践 (1)
- 神经网络学习-翻译 (4)
最新评论
-
3482561:
Android 面试题目之 线程池 -
daojin:
直接布局。
安卓高手之路之图形系统(6)requestLayout的流程 -
hety163:
没明白楼主所说的最后两段。如果一个相对布局中有多个子view, ...
安卓高手之路之图形系统(6)requestLayout的流程 -
jackuhan:
100篇!!!膜拜
安卓高手之路之 图形系统之 图形框架(1) -
ritterliu:
不错,按照流程把关键代码都贴出来了。谢谢分享
Android输入输出系统之TouchEvent流程
Custom Draw With List View and Tree View Controls
Most common controls can be handled in essentially the same way. However, the list view and tree view controls have some features that require a somewhat different approach to custom draw.
For Version 5.0 of the common controls, these two controls may display clipped text if you change the font by returning CDRF_NEWFONT. This behavior is necessary for backward compatibility with earlier versions of the common controls. If you want to change the font of a list view or tree view control, you will get better results if you send a CCM_SETVERSION message with the wParam value set to 5 before adding any items to the control.
Custom Draw With List View Controls
Because list view controls have subitems and multiple display modes, you will need to handle the NM_CUSTOMDRAW notification somewhat differently than for the other common controls.
For report mode:
The first NM_CUSTOMDRAW notification will have the dwDrawStage member of the associated NMCUSTOMDRAW structure set to CDDS_PREPAINT. Return CDRF_NOTIFYITEMDRAW.
You will then receive an NM_CUSTOMDRAW notification with dwDrawStage set to CDDS_ITEMPREPAINT. If you specify new fonts or colors and return CDRF_NEWFONT, all subitems of the item will be changed. If you want instead to handle each subitem separately, return CDRF_NOTIFYSUBITEMDRAW.
If you returned CDRF_NOTIFYITEMDRAW in the previous step, you will then receive an NM_CUSTOMDRAW notification for each subitem with dwDrawStage set to CDDS_SUBITEM | CDDS_PREPAINT. To change the font or color for that subitem, specify a new font or color and return CDRF_NEWFONT.
For the large icon, small icon, and list modes:
The first NM_CUSTOMDRAW notification will have the dwDrawStage member of the associated NMCUSTOMDRAW structure set to CDDS_PREPAINT. Return CDRF_NOTIFYITEMDRAW.
You will then receive an NM_CUSTOMDRAW notification with dwDrawStage set to CDDS_ITEMPREPAINT. You can change the fonts or colors of an item by specifying new fonts and colors and returning CDRF_NEWFONT. Because these modes do not have subitems, you will not receive any additional NM_CUSTOMDRAW notifications.
An example of a list view NM_CUSTOMDRAW notification handler is given in the next section.
Using Custom Draw
The following code fragment is a portion of a WM_NOTIFY handler that illustrates how to handle custom draw notifications sent to a list view control:
LPNMLISTVIEW pnm = (LPNMLISTVIEW)lParam;
switch (pnm->hdr.code){
...
case NM_CUSTOMDRAW:
LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)lParam;
switch(lplvcd->nmcd.dwDrawStage) {
case CDDS_PREPAINT :
return CDRF_NOTIFYITEMDRAW;
case CDDS_ITEMPREPAINT:
SelectObject(lplvcd->nmcd.hdc,
GetFontForItem(lplvcd->nmcd.dwItemSpec,
lplvcd->nmcd.lItemlParam) );
lplvcd->clrText = GetColorForItem(lplvcd->nmcd.dwItemSpec,
lplvcd->nmcd.lItemlParam);
lplvcd->clrTextBk = GetBkColorForItem(lplvcd->nmcd.dwItemSpec,
lplvcd->nmcd.lItemlParam);
/* At this point, you can change the background colors for the item
and any subitems and return CDRF_NEWFONT. If the list view control
is in report mode, you can simply return CDRF_NOTIFYSUBITEMREDRAW
to customize the item's subitems individually */
...
return CDRF_NEWFONT;
// or return CDRF_NOTIFYSUBITEMREDRAW;
case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
SelectObject(lplvcd->nmcd.hdc,
GetFontForSubItem(lplvcd->nmcd.dwItemSpec,
lplvcd->nmcd.lItemlParam,
lplvcd->iSubItem));
lplvcd->clrText = GetColorForSubItem(lplvcd->nmcd.dwItemSpec,
lplvcd->nmcd.lItemlParam,
lplvcd->iSubItem));
lplvcd->clrTextBk = GetBkColorForSubItem(lplvcd->nmcd.dwItemSpec,
lplvcd->nmcd.lItemlParam,
lplvcd->iSubItem));
/* This notification is received only if you are in report mode and
returned CDRF_NOTIFYSUBITEMREDRAW in the previous step. At
this point, you can change the background colors for the
subitem and return CDRF_NEWFONT.*/
...
return CDRF_NEWFONT;
}
...
}
The first NM_CUSTOMDRAW notification has the dwDrawStage member of the NMCUSTOMDRAW structure set to CDDS_PREPAINT. The handler returns CDRF_NOTIFYITEMDRAW to indicate that it wishes to modify one or more items individually. The control then sends an NM_CUSTOMDRAW notification with dwDrawStage set to CDDS_PREPAINT for each item. The handler returns CDRF_NOTIFYITEMDRAW to indicate that it wishes to modify the item.
If CDRF_NOTIFYITEMDRAW was returned in the previous step, the next NM_CUSTOMDRAW notification has dwDrawStage set to CDDS_ITEMPREPAINT. The handler gets the current color and font values. At this point, you can specify new values for small icon, large icon, and list modes. If the control is in report mode, you can also specify new values that will apply to all subitems of the item. If you have changed anything, return CDRF_NEWFONT. If the control is in report mode and you want to handle the subitems individually, return CDRF_NOTIFYSUBITEMREDRAW.
The final notification is only sent if the control is in report mode and you returned CDRF_NOTIFYSUBITEMREDRAW in the previous step. The procedure for changing fonts and colors is the same as that step, but it only applies to a single subitem. Return CDRF_NEWFONT to notify the control if the color or font was changed.
发表评论
-
Camera框架初探
2012-12-28 00:26 2677先解释一些概念,然后带着思考去解读 1.CameraServ ... -
打印一个字符串的所有排列。
2011-07-24 18:04 1188//打印一个字符串的所有排列。void printSequen ... -
快速排序
2011-04-16 21:26 965#include <stdio.h> #inclu ... -
ubuntu配置Android指南
2011-04-09 04:46 1471您还未登录!|登录|注册|帮助 CSDN首页资讯论坛博客下载搜 ... -
linux ubuntu mount success
2011-04-05 22:13 4033wangshuai@wangshuai-virtual-ma ... -
ubuntu VMware
2011-04-05 15:00 814http://www.linuxidc.com/Linux/2 ... -
Android源代码获得方法
2011-04-03 19:58 1006http://www.williamhua.com/2009/ ... -
什么是页表和页目录
2011-03-27 21:49 13874G内存分解为1M个内存页。 1K个页组成一个页表。 1K个页 ... -
pure abstract class(什么是纯抽象类?)
2011-03-18 22:55 1225下面是C++的创造者的回答,供你参考 Bjarne Stro ... -
自动化Build的方法如下所示
2011-02-05 23:43 1306#本文件自动进行build ... -
批处理
2011-02-04 17:19 1245批处理之家: http://www.bathome.n ... -
CString的高效版本
2011-02-03 17:55 1036#pragma once #include <stri ... -
自己写的share_ptr + Arry 来制作CString共享版本
2011-02-03 01:54 1636#include "MyStudyFile.h&qu ... -
自己写的share_ptr
2011-02-01 23:43 3101#pragma once namespace WSBoo ... -
什么叫做坐标系的平移和旋转.
2011-01-16 10:35 3211坐标系是个什么概念呢: X,Y,Z的轴坐标, ... -
总结一下这几天操作符的学习心得
2010-12-11 20:43 9511.关于map的operator[]:原形为 val_type ... -
函数返回应该是个右值吧,为啥能放在左边(红色标示的部分)?
2010-11-17 16:18 12471楼 class A1 { public: A ... -
优点和缺点
2010-11-13 19:52 732优点:非常爱学习,为人很大方。做事很投入,很刻苦。 缺点是: ... -
游戏开发框架
2010-11-09 21:57 1120class m_eventManger { }; c ... -
键盘消息
2010-11-08 20:50 997void CqjgzDlg::OnBnClickedWin ...
相关推荐
在IT领域,尤其是在Windows应用程序开发中,Visual C++与MFC(Microsoft Foundation Classes)框架是不可或缺的工具。这个“visual c++资源合集.zip”压缩包显然提供了关于使用MFC进行自定义绘制(自绘)控件的详细...
"cxGridChartView"是DevExpress组件库中的一个高级特性,主要用于在Delphi或C++ Builder开发的Windows应用程序中展示数据的图表视图。这个例子旨在帮助开发者了解如何利用cxGridChartView来创建交互式的数据可视化...
当需要更新颜色时,控件会发送LVN_ITEMCHANGED或NM_CUSTOMDRAW消息,开发者需要在相应消息处理函数中判断并处理颜色变更。 在VC++中,创建和定制这样的树列表控件通常涉及以下步骤: 1. 在资源编辑器中添加树列表...
在Windows编程领域,MFC(Microsoft Foundation Classes)是一个强大的库,它为开发人员提供了一种在C++中构建Windows应用程序的便捷方式。本项目“ListCtrlExp.zip”聚焦于MFC中的一个重要组件——ListCtrl,这是一...
在编程领域,自绘(Custom Draw)是一种技术,允许开发者完全控制控件的外观和行为,以实现独特的用户界面设计。本示例“无边框/有边框菜单自绘Demo”聚焦于如何利用编程技巧在Windows操作系统下创建自定义的菜单,...
7. **Custom Draw**:如果需要自定义List Control的绘制,可以利用其自绘特性,处理NM_CUSTOMDRAW通知。 8. **Virtual Mode**:对于大数据集,可以使用虚拟模式来提高性能,仅在需要时计算和显示列表项。 通过`WTL...
在Windows编程中,自绘(Custom Draw)是指应用程序控制控件的绘制过程,而不是完全依赖操作系统默认的绘制方式。通过自绘,开发者可以实现更加个性化和复杂的效果,如本例中的“背景图案”和“子项自绘风格”。自绘...
5. **自定义绘制**: 如果需要更复杂的绘制效果,比如自定义项的背景色或图标,可以处理NM_CUSTOMDRAW消息,并在其中进行绘制操作。 6. **数据绑定**: 在更复杂的应用中,List Control的数据可能来自数据库或其他...
而“对表头和列表单元进行颜色添加”可能是通过重绘或消息处理机制实现的,例如利用OnDrawItem和OnDrawColumnHeader成员函数来绘制列表项和列头,或者响应LVN_COLUMNCLICK和NM_CUSTOMDRAW消息,以实现动态的颜色变化...
在Microsoft Visual C++(简称VC)开发环境中,树形控件(Tree Control)是一种常见的用户界面元素,用于显示层次结构的数据。它常被用于文件管理器、设置面板或自定义菜单等场景。本主题将深入探讨如何在VC中有效地...
2. 为List Control添加自定义绘制支持,通过处理`NM_CUSTOMDRAW`通知消息。在这个消息处理函数中,你可以获取到绘图对象(如`NMLVCUSTOMDRAW`结构),然后使用其成员函数如`SetTextColor`和`SetBkColor`来设置文字和...
要实现`ComboBox`的工具提示功能,开发者通常需要在控件上处理WM_NOTIFY消息,特别是NM_CUSTOMDRAW子消息,以便在绘制控件时添加工具提示。此外,还需要处理WM_MOUSEHOVER和WM_MOUSELEAVE消息,以控制工具提示的显示...
自定义绘制(Custom Draw)是MFC提供的一种机制,允许开发者对控件的外观进行精细定制,以满足特定的界面设计需求。通常,Windows控件的绘制是由操作系统负责的,但自定义绘制则将这个责任交给了程序员,让你可以...
2. **自绘(Custom Draw)**:为了实现非标准的动画效果,我们需要覆盖CDialog类的OnPaint方法,进行自定义绘制。在这个过程中,可以使用GDI(Graphics Device Interface)或者GDI+来绘制对话框的各个部分,如背景、...
【描述】"a sample custom draw button control demo." 暗示了这个项目的核心在于自定义绘制按钮。在默认情况下,Windows系统中的按钮控件具有标准的外观和行为,但通过自定义绘制,开发者可以改变按钮的外观,如...
此外,可能还会涉及自绘(Custom Draw)技术,以自定义滚动条的外观和行为。 6. **调试与测试**:项目中很可能包含了调试步骤,比如设置断点、使用Visual Studio的调试工具来检查滚动条的大小变化和用户交互情况,...
最后,为了在鼠标悬停时改变行颜色,你需要处理`NM_CUSTOMDRAW`通知,通常在`OnCustomDraw`函数中完成。这里需要检查通知的类型和当前的状态,然后设置相应的颜色。 ```cpp void CMyListCtrl::OnCustomDraw(NMHDR* ...
4. **通知消息处理**:处理来自列表控件的消息,如NM_CUSTOMDRAW,这允许你在控件绘制时进行自定义操作。 5. **数据存储**:由于数据不在控件内部存储,你需要自己管理数据。这通常涉及到一个数据结构,如链表或...
在Windows编程中,自绘按钮(Custom Draw Button)是一种允许开发者根据自己的需求定制按钮外观的技术。在本案例中,我们关注的是使用Visual C++(VC)进行开发,并且该按钮设计适应于Windows XP操作系统。自绘按钮...
自绘(Custom Draw)是MFC中的一种技术,允许程序员控制控件的绘制过程,从而实现自定义的视觉效果。本资源包"SkinControls(自绘MFC基本控件 )"显然包含了一系列用于自绘MFC基本控件的代码示例,对于学习和理解如何...