CListCtrl 列表选中项非焦点时也是藍色

注意 要去掉Show Selection Always选项。


//列表选中项非焦点时也是藍色

void CZZHCCEditorDlg::OnRclickList3(NMHDR* pNMHDR, LRESULT* pResult) 

{

	// TODO: Add your control notification handler code here

	

	*pResult = 0;	

	

	NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );

	*pResult = CDRF_DODEFAULT;

	if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )

	{

		*pResult = CDRF_NOTIFYITEMDRAW;

	}

	else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )

	{

		*pResult = CDRF_NOTIFYSUBITEMDRAW;

	}

	else if ( (CDDS_ITEMPREPAINT | CDDS_SUBITEM) == pLVCD->nmcd.dwDrawStage )

	{

		int nItem = static_cast<int>( pLVCD->nmcd.dwItemSpec );

		

		if (m_ccFileTable.GetItemState(nItem, LVIS_SELECTED) == LVIS_SELECTED)

		{


pLVCD->clrText = RGB(255,255,255);
pLVCD->clrTextBk = RGB(49,150,255);


  

		}



		*pResult = CDRF_DODEFAULT;

	}

	

}

  

你可能感兴趣的:(list)