sorry,是DrawItem,
注意重载完要改一下形式virtual void DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct );
注意重载完要改一下形式virtual void DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct );
解决方案 »
- Url编码针对TCHAR类型,给个例子吧,最好不要用MFC,不熟悉
- 窗口尺寸
- 用DataGrid控件怎么通过单击某行,把该行的数据以对话框的形式显示出来?
- 如何实现CWnd 类指针与 CButton 类对象之间的关系与转换
- 如何在程序中嵌入IE控件及其工具栏?
- 磁盘映射问题
- 为什么在成员变量中看不到加入的RadioButton的Control IDs???
- 急,天亮前要解决!!COM组件自注册的问题!!!
- 怎样显示程序的 标题 ?
- 关于钩子函数(SetWindowsHookEx)的问题。
- *******我要一个这样的类:显示淡入淡出的菜单(最好还能有半透明的功能) ***************
- 什么叫“网恋”?
{
NMLVCUSTOMDRAW *pCD = (NMLVCUSTOMDRAW*)pNMHDR;
switch (pCD->nmcd.dwDrawStage)
{
case CDDS_PREPAINT:
*pResult = CDRF_NOTIFYITEMDRAW;
break;
case CDDS_ITEMPREPAINT | CDDS_SUBITEM:
*pResult = CDRF_NOTIFYSUBITEMDRAW | CDRF_NOTIFYPOSTPAINT;
break;
case CDDS_ITEMPOSTPAINT | CDDS_SUBITEM:
{
CDC* pDC = CDC::FromHandle(pCD->nmcd.hdc);
.....
.....
break;
}
default:
if (!(pCD->nmcd.uItemState & CDIS_FOCUS))
*pResult = CDRF_DODEFAULT;
else
*pResult = CDRF_NOTIFYSUBITEMDRAW;
break;
}
}
//{{AFX_MSG_MAP(CCheckNetWorkDlg)
.....
//}}AFX_MSG_MAP
.....
ON_NOTIFY(NM_CUSTOMDRAW, IDC_REPORT, OnCustomdrawList) //定义消息
END_MESSAGE_MAP()void CCheckNetWorkDlg::OnCustomdrawList ( NMHDR* pNMHDR, LRESULT* pResult )
{
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;
// crText = RGB(0,0,0);
if (m_bHost[pLVCD->nmcd.dwItemSpec]) //指定要改变颜色的Item
crText = RGB(255,255,255);
else
crText = RGB(255,0,0); // Store the color back in the NMLVCUSTOMDRAW struct.
// pLVCD->clrText = crText;
pLVCD->clrTextBk=crText; // Tell Windows to paint the control itself.
*pResult = CDRF_DODEFAULT;
}
}