//Create A CDC from the SDK struct passed in
CDC* pDC = CDC::FromHandle(lpDIS->hDC);
if (lpDIS->itemState & ODS_SELECTED)//被选择的时候
{
// Set the text background and foreground colors
crBackground = GetSysColor (COLOR_HIGHLIGHT);//背景
crText = GetSysColor (COLOR_HIGHLIGHTTEXT);//文本颜色
}
else if(lpDIS->itemState & ODS_DISABLED)//禁用的时候
{
// Set the text background and foreground colors to the standard window
// colors
crBackground = GetSysColor (COLOR_WINDOW);//背景颜色
crText = GetSysColor (COLOR_WINDOWTEXT);//文本颜色
}
pDC->SetBkColor(crBackground);
pDC->SetTextColor(crText);
//If the item is selected, draw the selection background
if ((lpDIS->itemState & ODS_SELECTED) &&
(lpDIS->itemAction & (ODA_SELECT | ODA_DRAWENTIRE)))
{
// item has been selected - draw selection rectangle
CBrush br(crBackground);
pDC->FillRect(&lpDIS->rcItem, &br);
}
//If the item is not selected, draw a white background
if (!(lpDIS->itemState & ODS_SELECTED) &&
(lpDIS->itemAction & ODA_SELECT))
{
// Item has been de-selected -- remove selection rectangle
CBrush br(crBackground);
pDC->FillRect(&lpDIS->rcItem, &br);
}
}
}