How to change color of CListCtrl column

前端 未结 3 1172
北荒
北荒 2021-01-23 16:06

I want to change the background color of a specific column to a color of the dialog (grey). How can I achive it?

void CUcsOpTerminalDlg::OnCustomdrawFeatureList(         


        
3条回答
  •  遇见更好的自我
    2021-01-23 16:45

    The custom draw API does not work exactly as advertised. Anyway, the following code will paint the second column green:

    LPNMLVCUSTOMDRAW pNMLVCD = reinterpret_cast(pNMHDR);
    *pResult = CDRF_DODEFAULT;
    switch( pNMLVCD->nmcd.dwDrawStage )
    {
    case CDDS_PREPAINT:
        *pResult = CDRF_NOTIFYITEMDRAW;
        break;
    
    case CDDS_ITEMPREPAINT:
        *pResult = CDRF_NOTIFYSUBITEMDRAW;
        break;
    
    case CDDS_ITEMPREPAINT | CDDS_SUBITEM:
        if( pNMLVCD->iSubItem == 1 )
            pNMLVCD->clrTextBk = RGB(0,255,0);
        break;
    }
    

提交回复
热议问题