解决方案 »
- 在CFormView的单文档程序中使用CTabCtrl,初始化显示如何更新?
- 求一个ANSI字符的不管大小写最快的检索函数
- 临界区应怎么使用啊??
- 下周去华为面试,大家给提点意见~~~
- 奇怪了,我的windows 2000居然不支持Overlapped I/O和IOCP了
- activeX控件的动态创建问题 to(Microsoftadherent(王万新) )
- 如何采用模板实现这个简单的排序功能?
- 网络问题
- CSDN有自己的FREE软件库吗?
- CString 类型如何转换成字符型的指针
- 使用UpdateLayeredWindow创建异形窗口所遇到的奇怪问题
- inline钩子 能移植到mobile 平台吗?顺便问下钩子是改函数代码还是地址??
void CStringEditListCtrl::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
//draw each item.set txt color,bkcolor....
NMLVCUSTOMDRAW* pNMLVCustomDraw = (NMLVCUSTOMDRAW*)pNMHDR;
// Take the default processing unless we set this to something else below.
*pResult = CDRF_DODEFAULT;
// First thing - check the draw stage. If it's the control's prepaint
// stage, then tell Windows we want messages for every item.
if (pNMLVCustomDraw->nmcd.dwDrawStage == CDDS_PREPAINT)
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if (pNMLVCustomDraw->nmcd.dwDrawStage == CDDS_ITEMPREPAINT)
{
// This is the notification message for an item. We'll request
// notifications before each subitem's prepaint stage.
*pResult = CDRF_NOTIFYSUBITEMDRAW;
}
else if (pNMLVCustomDraw->nmcd.dwDrawStage == (CDDS_ITEMPREPAINT | CDDS_SUBITEM))
{
int iItem = (int)pNMLVCustomDraw->nmcd.dwItemSpec;
int iSubItem = pNMLVCustomDraw->iSubItem;
CDC* pDC = CDC::FromHandle(pNMLVCustomDraw->nmcd.hdc);
CString strItemText = GetItemText(iItem, iSubItem);
CRect rcItem, rcText;
GetSubItemRect(iItem, iSubItem, LVIR_LABEL, rcItem);
rcText = rcItem;
CSize size = pDC->GetTextExtent(strItemText);
size.cx = GetColumnWidth(iSubItem);
COLORREF crOldTextColor = pDC->GetTextColor(); if(m_bFocus)
{
if((m_nItem == iItem) && (m_nSubItem == iSubItem))
{
if(m_bHighLight)
{
pDC->SetTextColor(::GetSysColor(COLOR_HIGHLIGHTTEXT));
pDC->FillSolidRect(&rcText, ::GetSysColor(COLOR_HIGHLIGHT));
}
pDC->DrawFocusRect(&rcText);
}
} rcItem.left += MOVEEDITTEXTRIGHT;
pDC->DrawText(strItemText, &rcItem, DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS | DT_NOCLIP); pDC->SetTextColor(crOldTextColor); // We've painted everything.
*pResult = CDRF_SKIPDEFAULT;
}
}
{
// This is the notification message for an item. We'll request
// notifications before each subitem's prepaint stage.
*pResult = CDRF_NOTIFYSUBITEMDRAW;
}
这段代码的问题.