ColorListCtrl.cpp
资源名称:ROA3.40.rar [点击查看]
上传用户:tianheyiqi
上传日期:2010-04-16
资源大小:282k
文件大小:2k
源码类别:
外挂编程
开发平台:
Visual C++
- // ColorListCtrl.cpp : implementation file
- //
- #include "stdafx.h"
- #include "ColorListCtrl.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CColorListCtrl
- CColorListCtrl::CColorListCtrl()
- {
- }
- CColorListCtrl::~CColorListCtrl()
- {
- }
- BEGIN_MESSAGE_MAP(CColorListCtrl, CListCtrl)
- //{{AFX_MSG_MAP(CColorListCtrl)
- //}}AFX_MSG_MAP
- ON_NOTIFY_REFLECT(NM_CUSTOMDRAW, OnCustomdrawMyList)
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CColorListCtrl message handlers
- void CColorListCtrl::OnCustomdrawMyList (NMHDR* pNMHDR, LRESULT* pResult)
- {
- NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
- if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
- {
- *pResult = CDRF_NOTIFYITEMDRAW;
- }
- else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
- {
- // This is the notification message for an item. We'll request
- // notifications before each subitem's prepaint stage.
- *pResult = CDRF_NOTIFYSUBITEMDRAW;
- int nItem = static_cast<int>( pLVCD->nmcd.dwItemSpec );
- for (int i = m_ArrayColorInfo.GetSize() - 1; i >= 0 ; --i)
- {
- if (nItem == m_ArrayColorInfo[i].nIndex)
- {
- pLVCD->clrText = m_ArrayColorInfo[i].textColor;
- pLVCD->clrTextBk = m_ArrayColorInfo[i].bkColor;
- return;
- }
- }
- // Tell Windows to paint the control itself.
- *pResult = CDRF_DODEFAULT;
- }
- }
- void CColorListCtrl::SetRowColor(int nIndex, COLORREF bkColor, COLORREF textColor)
- {
- m_ColorInfo.nIndex = nIndex;
- m_ColorInfo.bkColor = bkColor;
- m_ColorInfo.textColor = textColor;
- m_ArrayColorInfo.Add(m_ColorInfo);
- }