Пример #1
0
LRESULT GUI::handleCustomDraw(NMLVCUSTOMDRAW& data) {
	auto item = static_cast<int>(data.nmcd.dwItemSpec);
//	auto column = data.iSubItem; // Potential per-subItem coloring

	if (data.nmcd.dwDrawStage == CDDS_PREPAINT) {
		return CDRF_NOTIFYITEMDRAW;
	}

	if ((data.nmcd.dwDrawStage & CDDS_ITEMPREPAINT) == CDDS_ITEMPREPAINT && data.dwItemType == LVCDI_ITEM && data.nmcd.lItemlParam) {

		auto rect = table->getRect(item, LVIR_BOUNDS);

		Item* it = (Item*)data.nmcd.lItemlParam;
		if (data.nmcd.hdr.hwndFrom == table->handle()) {

			if (/*(eColorFormat) &&*/ it->protocol == _T("ADC")) {
				data.clrText = RGB(255, 51, 51);
			} else if (it->protocol == _T("NMDC")) {
				data.clrText = RGB(102, 0, 204);
			} else if (it->protocol == _T("UDP")) {
				data.clrText = RGB(0, 255, 28);
			}

		}
		
		/*
		HFONT font = nullptr;
		auto ret = data.nmcd.lItemlParam;
		if (ret == CDRF_NEWFONT && font) {
			::SelectObject(data.nmcd.hdc, font);
		}
		return ret;
		*/
	}

	return CDRF_DODEFAULT;
}