ListView color interlaced

xiaoxiao2021-03-06  21

Void cvcsendisdmdlg :: oncustomDraw (nmhdr * pnmhdr, lresult * pRESULT) {

NmlvcustomDraw * plvcd = (nmlvcustomDraw *) PNMHDR;

* PRESULT = CDRF_DODEFAULT;

IF (PLVCD-> NMCD.dwdrawStage == CDDS_PREPAINT) {* PRESULT = CDRF_NOTIFYITEMDRAW;} Else IF (PLVCD-> nmcd.dwdrawstage == CDDS_ItemprepAint) {

* PResult = CDRF_NOTIFYSUBITEMDRAW;} else if (pLVCD-> nmcd.dwDrawStage == (CDDS_ITEMPREPAINT | CDDS_SUBITEM)) {int nItem = pLVCD-> nmcd.dwItemSpec; int nSubItem = pLVCD-> iSubItem; CRect rect; CString str = "" ; str = m_listctr.GetItemText (nItem, nSubItem); CDC * pDC = CDC :: FromHandle (pLVCD-> nmcd.hdc); m_listctr.GetSubItemRect (nItem, nSubItem, LVIR_BOUNDS, rect); if (m_listctr.GetItemState (nItem, LVIS_SELECTED) DRAWLISTITEM (STR, PDC, 0x00FF00, 0x0000FF, Rect); Else IF (0 == Nitem% 2) DrawlistItem (STR, PDC, 0x0000FF, 0xFFfee, Rect); Else DrawlistItem (STR, PDC, 0x00FF00, 0x00FFF, RECT);

* PRESULT = CDRF_SKIPDEFAULT;}

void CVcSendISDMDlg :: DrawListItem (CString str, CDC * pDC, COLORREF crText, COLORREF crBkgnd, CRect & rect) {pDC-> FillSolidRect (& rect, crBkgnd); if (str.IsEmpty ()!) {UINT nFormat = DT_VCENTER | DT_LEFT | DT_EXPANDTABS; PDC-> setBkmode (transparent); PDC-> setTextColor (CRTEXT); PDC-> setBkcolor (crbkgnd); str = "" Str; PDC-> DrawText (Str, & Rect, nformat);

}

转载请注明原文地址:https://www.9cbs.com/read-39552.html

New Post(0)