/// <summary>
/// Handle the NM_CUSTOMDRAW message to implement custom draw.
/// </summary>
/// <param name="pNMLVCD">Information specific to an NM_CUSTOMDRAW notification code.</param>
LRESULT CustomDrawListControl::OnCustomDraw(LPNMLVCUSTOMDRAW pNMLVCD)
{
    switch(pNMLVCD->nmcd.dwDrawStage)
    {
    case CDDS_PREPAINT:
        return CDRF_NOTIFYITEMDRAW;

    case CDDS_ITEMPREPAINT:
        return CDRF_NOTIFYSUBITEMDRAW;

    case CDDS_SUBITEM | CDDS_ITEMPREPAINT:
        return OnCustomDrawCell(pNMLVCD);
    }

    return CDRF_DODEFAULT;
}
Example #2
0
void CStockList::OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult)
{
	NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>(pNMHDR);
	int nRow = (int)pLVCD->nmcd.dwItemSpec;

	*pResult = CDRF_DODEFAULT;

	// Allow column-traits to perform their custom drawing
	if (pLVCD->nmcd.dwDrawStage & CDDS_SUBITEM)
	{
		OnCustomDrawRow(nRow, pLVCD, pResult);
		if (*pResult & CDRF_SKIPDEFAULT)
			return;	// Everything is handled by the row-trait

		int nCol = pLVCD->iSubItem;
		OnCustomDrawCell(nRow, nCol, pLVCD, pResult);
		if (*pResult & CDRF_SKIPDEFAULT)
			return;	// Everything is handled by the column-trait
	}

	// Always perform drawing of cell-focus rectangle
	switch (pLVCD->nmcd.dwDrawStage)
	{
	case CDDS_PREPAINT:
		*pResult |= CDRF_NOTIFYITEMDRAW;
		break;

		// Before painting a row
	case CDDS_ITEMPREPAINT:
		{
			*pResult |= CDRF_NOTIFYPOSTPAINT;	// Ensure row-traits gets called
			*pResult |= CDRF_NOTIFYSUBITEMDRAW;	// Ensure column-traits gets called

			// 			SCORE m_Win = ((CUserInfoItem * )GetItemData(nRow))->m_tagUMUserScoreSet.lMaxWin1/*_ttoi(GetItemText(nRow,11))*/;
			// 			SCORE m_Warning = ((CUserInfoItem * )GetItemData(nRow))->m_tagUMUserScoreSet.lNotifyMaxWin/*_ttoi(GetItemText(nRow,17))*/;
			// 			SCORE m_Warning1 = ((CUserInfoItem * )GetItemData(nRow))->m_tagUMUserScoreSet.lNotifyMaxLost/*_ttoi(GetItemText(nRow,18))*/;
			// 
			// 			if (m_Win >= m_Warning || m_Win <= m_Warning1)
			// 			{
			// 				pLVCD->clrText = RGB(255,0, 0);
			// 			}
			// 			if(((CUserInfoItem * )GetItemData(nRow))->m_tagUMUserScoreSet.nVipType == 1)
			// 			{
			// 				pLVCD->clrText = RGB(0,0, 255);
			// 			}
			// 			if(((CUserInfoItem * )GetItemData(nRow))->m_tagUMUserScoreSet.wOnline == 0)
			// 			{
			// 				pLVCD->clrText = RGB(188,188,173);
			// 			}

			//pLVCD->clrText = RGB(0,0,0);

			*pResult = CDRF_DODEFAULT;
			OnCustomDrawRow(nRow, pLVCD, pResult);  
		} break;

		// After painting the entire row
	case CDDS_ITEMPOSTPAINT:
		{
			OnCustomDrawRow(nRow, pLVCD, pResult);
		} break;
	}
}