m_List.SetBkColor(RGB(255, 255,0));仅仅是修改整个背景。
没有现成的函数调用~谁写过的,讲讲方法或者代码贴一下,谢谢~~
7 个解决方案
#1
http://vckbase.com/document/viewdoc/?id=1480
重载
重载
#2
具体该怎么样写代码哦?代码写到什么函数里面~~具体指教一下,~
#3
我前两天查了好多资料,正好给你。 也可以重载DrawItem,但是比较麻烦,要自己绘
void C_CodeList::OnCustomdrawList(NMHDR *pNMHDR, LRESULT *pResult)
{
// TODO: Add your control notification handler code here
LPNMLVCUSTOMDRAW pnmCustDraw = (LPNMLVCUSTOMDRAW)pNMHDR;
TRACEINFO(L"OnNMCustomdrawList1");
switch(pnmCustDraw->nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
*pResult = CDRF_NOTIFYITEMDRAW ;
break;
case CDDS_ITEMPREPAINT:
{
COLORREF clrCodeInvalidColor;
clrCodeInvalidColor = RGB(0xff, 0x00, 0x00);
pnmCustDraw->clrTextBk = clrCodeInvalidColor;
}
break;
}
case CDDS_SUBITEM:
{
break;
}
case CDDS_ITEMPOSTPAINT:
{
*pResult = CDRF_DODEFAULT;
break;
}
default:
*pResult = CDRF_DODEFAULT;
break;
}
return ;
}
void C_CodeList::OnCustomdrawList(NMHDR *pNMHDR, LRESULT *pResult)
{
// TODO: Add your control notification handler code here
LPNMLVCUSTOMDRAW pnmCustDraw = (LPNMLVCUSTOMDRAW)pNMHDR;
TRACEINFO(L"OnNMCustomdrawList1");
switch(pnmCustDraw->nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
*pResult = CDRF_NOTIFYITEMDRAW ;
break;
case CDDS_ITEMPREPAINT:
{
COLORREF clrCodeInvalidColor;
clrCodeInvalidColor = RGB(0xff, 0x00, 0x00);
pnmCustDraw->clrTextBk = clrCodeInvalidColor;
}
break;
}
case CDDS_SUBITEM:
{
break;
}
case CDDS_ITEMPOSTPAINT:
{
*pResult = CDRF_DODEFAULT;
break;
}
default:
*pResult = CDRF_DODEFAULT;
break;
}
return ;
}
#4
下面是别人的代码 希望对你有帮助
响应NM_CUSTOMDRAW进行重绘。。下面的代码演示了让ListCtrl隔行颜色不同的效果:
ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw)
void CMyListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)pNMHDR;
*pResult = 0;
switch(lplvcd->nmcd.dwDrawStage)
{
case CDDS_PREPAINT :
*pResult = CDRF_NOTIFYITEMDRAW;
break;
case CDDS_ITEMPREPAINT:
*pResult = CDRF_NOTIFYSUBITEMDRAW;
break;
case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
if(lplvcd->nmcd.dwItemSpec % 2)
{
lplvcd->clrTextBk = RGB(255,255,200);
}
else
{
lplvcd->clrTextBk = RGB(255,255,255);
}
*pResult = CDRF_NEWFONT;
break;
}
}
响应NM_CUSTOMDRAW进行重绘。。下面的代码演示了让ListCtrl隔行颜色不同的效果:
ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw)
void CMyListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)pNMHDR;
*pResult = 0;
switch(lplvcd->nmcd.dwDrawStage)
{
case CDDS_PREPAINT :
*pResult = CDRF_NOTIFYITEMDRAW;
break;
case CDDS_ITEMPREPAINT:
*pResult = CDRF_NOTIFYSUBITEMDRAW;
break;
case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
if(lplvcd->nmcd.dwItemSpec % 2)
{
lplvcd->clrTextBk = RGB(255,255,200);
}
else
{
lplvcd->clrTextBk = RGB(255,255,255);
}
*pResult = CDRF_NEWFONT;
break;
}
}
#5
对于以上代码,都可以,我想在运行的过程中修改,比如,我有个按钮,按下去就可以改变指定行的颜色,这样可以吗
#6
应该可以啊。获取你所选中的行的索引值。m_list.GetCurSel(),然后将楼上说的方法写成函数ChangeItemColor(int nSelect),就可以啊
#7
加载的时候就调用了OnCustomDraw,而且还有NMHDR* pNMHDR, LRESULT* pResult这些参数,我点了以后哪去这些参数值啊
#1
http://vckbase.com/document/viewdoc/?id=1480
重载
重载
#2
具体该怎么样写代码哦?代码写到什么函数里面~~具体指教一下,~
#3
我前两天查了好多资料,正好给你。 也可以重载DrawItem,但是比较麻烦,要自己绘
void C_CodeList::OnCustomdrawList(NMHDR *pNMHDR, LRESULT *pResult)
{
// TODO: Add your control notification handler code here
LPNMLVCUSTOMDRAW pnmCustDraw = (LPNMLVCUSTOMDRAW)pNMHDR;
TRACEINFO(L"OnNMCustomdrawList1");
switch(pnmCustDraw->nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
*pResult = CDRF_NOTIFYITEMDRAW ;
break;
case CDDS_ITEMPREPAINT:
{
COLORREF clrCodeInvalidColor;
clrCodeInvalidColor = RGB(0xff, 0x00, 0x00);
pnmCustDraw->clrTextBk = clrCodeInvalidColor;
}
break;
}
case CDDS_SUBITEM:
{
break;
}
case CDDS_ITEMPOSTPAINT:
{
*pResult = CDRF_DODEFAULT;
break;
}
default:
*pResult = CDRF_DODEFAULT;
break;
}
return ;
}
void C_CodeList::OnCustomdrawList(NMHDR *pNMHDR, LRESULT *pResult)
{
// TODO: Add your control notification handler code here
LPNMLVCUSTOMDRAW pnmCustDraw = (LPNMLVCUSTOMDRAW)pNMHDR;
TRACEINFO(L"OnNMCustomdrawList1");
switch(pnmCustDraw->nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
*pResult = CDRF_NOTIFYITEMDRAW ;
break;
case CDDS_ITEMPREPAINT:
{
COLORREF clrCodeInvalidColor;
clrCodeInvalidColor = RGB(0xff, 0x00, 0x00);
pnmCustDraw->clrTextBk = clrCodeInvalidColor;
}
break;
}
case CDDS_SUBITEM:
{
break;
}
case CDDS_ITEMPOSTPAINT:
{
*pResult = CDRF_DODEFAULT;
break;
}
default:
*pResult = CDRF_DODEFAULT;
break;
}
return ;
}
#4
下面是别人的代码 希望对你有帮助
响应NM_CUSTOMDRAW进行重绘。。下面的代码演示了让ListCtrl隔行颜色不同的效果:
ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw)
void CMyListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)pNMHDR;
*pResult = 0;
switch(lplvcd->nmcd.dwDrawStage)
{
case CDDS_PREPAINT :
*pResult = CDRF_NOTIFYITEMDRAW;
break;
case CDDS_ITEMPREPAINT:
*pResult = CDRF_NOTIFYSUBITEMDRAW;
break;
case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
if(lplvcd->nmcd.dwItemSpec % 2)
{
lplvcd->clrTextBk = RGB(255,255,200);
}
else
{
lplvcd->clrTextBk = RGB(255,255,255);
}
*pResult = CDRF_NEWFONT;
break;
}
}
响应NM_CUSTOMDRAW进行重绘。。下面的代码演示了让ListCtrl隔行颜色不同的效果:
ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomDraw)
void CMyListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
LPNMLVCUSTOMDRAW lplvcd = (LPNMLVCUSTOMDRAW)pNMHDR;
*pResult = 0;
switch(lplvcd->nmcd.dwDrawStage)
{
case CDDS_PREPAINT :
*pResult = CDRF_NOTIFYITEMDRAW;
break;
case CDDS_ITEMPREPAINT:
*pResult = CDRF_NOTIFYSUBITEMDRAW;
break;
case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
if(lplvcd->nmcd.dwItemSpec % 2)
{
lplvcd->clrTextBk = RGB(255,255,200);
}
else
{
lplvcd->clrTextBk = RGB(255,255,255);
}
*pResult = CDRF_NEWFONT;
break;
}
}
#5
对于以上代码,都可以,我想在运行的过程中修改,比如,我有个按钮,按下去就可以改变指定行的颜色,这样可以吗
#6
应该可以啊。获取你所选中的行的索引值。m_list.GetCurSel(),然后将楼上说的方法写成函数ChangeItemColor(int nSelect),就可以啊
#7
加载的时候就调用了OnCustomDraw,而且还有NMHDR* pNMHDR, LRESULT* pResult这些参数,我点了以后哪去这些参数值啊