如何控制列表控件的一行颜色显示

时间:2013-03-31 02:35:18
【文件属性】:
文件名称:如何控制列表控件的一行颜色显示
文件大小:16KB
文件格式:RAR
更新时间:2013-03-31 02:35:18
C 列表控件 理解这个程序的关键是理解Common控件的WM_NOTIFY消息 这个消息先发给控件自身,自己处理后再决定要不要发给父窗口。 WM_NOTIFY的消息通知码有很多种,如下表 Notification Sent When NM_CLICK The control is clicked with the left mouse button. NM_DBLCLK The control is double-clicked with the left mouse button. NM_RCLICK The control is clicked with the right mouse button. NM_RDBLCLK The control is double-clicked with the right mouse button. NM_RETURN The Enter key is pressed while the control has the input focus. NM_KILLFOCUS The control loses the input focus. NM_SETFOCUS The control gains the input focus. NM_OUTOFMEMORY An operation on the control has failed because of insufficient memory. 还有本程序中用到的 NM_CUSTOMDRAW是在绘制控件时产生。这些消息可以通过MFC定义的宏ON_NOTIFY_REFLECT映射到类的处理函数,不过VC6.0下要自己手动添加,ClassWizard里面没这些消息。 ClistCtrl类的绘制过程有很多状态,如CDDS_PREPAINT, CDDS_ITEM,CDDS_ITEMPREPAINT,CDDS_SUBITEM,以及相应的数据结构,这些东东大家可以参考MSDN。另外一个就是用了CMap类模板的变量存储了列表控件各行的颜色,重画时再读出。 希望这个程序对大家起到参考作用,有疑问的可以发mail:wt-jzy-lj@263.net
【文件预览】:
CtlListBoxColor
----ListCtrl()
--------ListCtrlDlg.cpp(5KB)
--------ListCtrlDlg.h(1KB)
--------StdAfx.cpp(210B)
--------MyList.h(1KB)
--------ListCtrl.cpp(2KB)
--------ListCtrl.dsw(539B)
--------ReadMe.txt(4KB)
--------StdAfx.h(1KB)
--------Resource.h(778B)
--------res()
--------ListCtrl.dsp(4KB)
--------ListCtrl.h(1KB)
--------ListCtrl.rc(5KB)
--------MyList.cpp(1KB)
----如何控制列表控件的一行颜色显示.doc(21KB)

网友评论

  • 不错,主要是学习一下