(1)重载CListCtrl的OnCustomdrawList()函数
(2)afx_msg void OnCustomdrawList(NMHDR*, LRESULT*);
(3) 消息 ON_NOTIFY(NM_CUSTOMDRAW, IDC_LIST, OnCustomdrawList)
(4)
void CToopView::OnCustomdrawList( NMHDR* pNMHDR, LRESULT* pResult )
{
CTime t_Time=CTime::GetCurrentTime();
CString strTime;
strTime.Format("%4d/%02d/%02d",t_Time.GetYear()
,t_Time.GetMonth()
,t_Time.GetDay());
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast< NMLVCUSTOMDRAW*> ( pNMHDR ); // Take the default processing unless we set this to something else below.
*pResult = 0; // First thing - check the draw stage. If it's the control's prepaint
// stage, then tell Windows we want messages for every item.
if ( CDDS_PREPAINT == pLVCD-> nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if ( CDDS_ITEMPREPAINT == pLVCD-> nmcd.dwDrawStage )
{
// This is the prepaint stage for an item. Here's where we set the
// item's text color. Our return value will tell Windows to draw the
// item itself, but it will use the new color we set here.
// We'll cycle the colors through red, green, and light blue.
COLORREF crText;
UINT nRow;
nRow=pLVCD-> nmcd.dwItemSpec;
if(m_List.GetItemText(nRow,11)< =strTime)
crText = RGB(255,0,0);
else
crText = RGB(0,0,0); // Store the color back in the NMLVCUSTOMDRAW struct.
// pLVCD-> clrText = crText;
pLVCD-> clrText=crText;
// Tell Windows to paint the control itself.
*pResult = CDRF_DODEFAULT;
}
} 上面是我程序中的一段代码,仅功参考!
(2)afx_msg void OnCustomdrawList(NMHDR*, LRESULT*);
(3) 消息 ON_NOTIFY(NM_CUSTOMDRAW, IDC_LIST, OnCustomdrawList)
(4)
void CToopView::OnCustomdrawList( NMHDR* pNMHDR, LRESULT* pResult )
{
CTime t_Time=CTime::GetCurrentTime();
CString strTime;
strTime.Format("%4d/%02d/%02d",t_Time.GetYear()
,t_Time.GetMonth()
,t_Time.GetDay());
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast< NMLVCUSTOMDRAW*> ( pNMHDR ); // Take the default processing unless we set this to something else below.
*pResult = 0; // First thing - check the draw stage. If it's the control's prepaint
// stage, then tell Windows we want messages for every item.
if ( CDDS_PREPAINT == pLVCD-> nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if ( CDDS_ITEMPREPAINT == pLVCD-> nmcd.dwDrawStage )
{
// This is the prepaint stage for an item. Here's where we set the
// item's text color. Our return value will tell Windows to draw the
// item itself, but it will use the new color we set here.
// We'll cycle the colors through red, green, and light blue.
COLORREF crText;
UINT nRow;
nRow=pLVCD-> nmcd.dwItemSpec;
if(m_List.GetItemText(nRow,11)< =strTime)
crText = RGB(255,0,0);
else
crText = RGB(0,0,0); // Store the color back in the NMLVCUSTOMDRAW struct.
// pLVCD-> clrText = crText;
pLVCD-> clrText=crText;
// Tell Windows to paint the control itself.
*pResult = CDRF_DODEFAULT;
}
} 上面是我程序中的一段代码,仅功参考!
解决方案 »
- windows程序设计画线问题 在线等
- 菜单加入位图出现访问地址错误
- 点击消息框中的确定按钮后出现“Debug Assetion Failed”,请大家帮帮忙!
- 如何通过一台机子的IP 的到该机子的系统时间??
- 如何设置Tree控件中的初始目录
- 请问皮肤库到底是什么东西啊?
- 请问高程中下午试题的软件设计的题目要看什么书,怎么学习?
- 求助,谢谢
- 请问在已经知道窗口句柄的情况下,如何判断一个窗口是 button,edit ?
- 如何判断一指定目录是否存在,如不存在新建之?
- 怎样在工程资源中import真彩色位图
- 狂送100分!!讨论不需要创建拨号连接就可以用rasdial()拨号(win2000pro)
如何不用鼠标点取,如何设置颜色?