[code]void CListView::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
CListCtrl* listCtrl = GetListCtrl();
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
// Take the default processing unless we set this to something else below.
*pResult = CDRF_DODEFAULT;
if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
{
int nItem = static_cast<int>( pLVCD->nmcd.dwItemSpec ); // 각 라인 설정....
// 글자색 바꾸기..
COLORREF crTextColor, crBkColor;
if(listCtrl.GetItemText(nItem,0) == "aa") // 첫라인 첫째 글자가 aa 일경우 해당
// 라인색상 변경
{
crTextColor = RGB(200,200,200); // 해당 라인의 글자 색 설정..
crBkColor = RGB(238, 245, 222); // 해당 라인의 배경 색 설정..
}
else
{
crTextColor = RGB(0,0,0); // 해당 라인의 글자 색 설정..
crBkColor = RGB(238, 236, 222); // 해당 라인의 배경 색 설정..
}
// Store the color back in the NMLVCUSTOMDRAW struct.
pLVCD->clrText = crTextColor; // 해당 라인의 글자 색 변경..
pLVCD->clrTextBk = crBkColor; // 해당 라인의 배경 색 변경..
// Tell Windows to paint the control itself.
*pResult = CDRF_DODEFAULT;
}
}
[/code]
{
CListCtrl* listCtrl = GetListCtrl();
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
// Take the default processing unless we set this to something else below.
*pResult = CDRF_DODEFAULT;
if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
{
int nItem = static_cast<int>( pLVCD->nmcd.dwItemSpec ); // 각 라인 설정....
// 글자색 바꾸기..
COLORREF crTextColor, crBkColor;
if(listCtrl.GetItemText(nItem,0) == "aa") // 첫라인 첫째 글자가 aa 일경우 해당
// 라인색상 변경
{
crTextColor = RGB(200,200,200); // 해당 라인의 글자 색 설정..
crBkColor = RGB(238, 245, 222); // 해당 라인의 배경 색 설정..
}
else
{
crTextColor = RGB(0,0,0); // 해당 라인의 글자 색 설정..
crBkColor = RGB(238, 236, 222); // 해당 라인의 배경 색 설정..
}
// Store the color back in the NMLVCUSTOMDRAW struct.
pLVCD->clrText = crTextColor; // 해당 라인의 글자 색 변경..
pLVCD->clrTextBk = crBkColor; // 해당 라인의 배경 색 변경..
// Tell Windows to paint the control itself.
*pResult = CDRF_DODEFAULT;
}
}
[/code]
'Windows > MFC' 카테고리의 다른 글
CHeaderCtrl Skin image (0) | 2013.10.02 |
---|---|
CListCtrl Changing color of gridlines in a listctrl (0) | 2013.10.02 |
NM_CUSTOMDRAW (LISTCTRL) (0) | 2013.10.02 |
Visual Studio 언어 문제 (지역 문제) (0) | 2013.10.02 |
CEdit CBrush background image 에디트에 배경 이미지 깔기 (0) | 2013.10.02 |