#pragma once


// CListItem
class CListItem
{
public:
	CListItem(CString szItemName, UINT nBitMap)
	{
		lstrcpy(m_szItemName, szItemName);
		m_nBitMap = nBitMap;
	}
public:
	TCHAR m_szItemName[MAX_PATH];
	UINT  m_nBitMap;
};

// CListBoxEx

class  CListBoxEx : public CListBox
{
	DECLARE_DYNAMIC(CListBoxEx)

public:
	CListBoxEx();
	virtual ~CListBoxEx();

	// 覆盖
	virtual void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
	virtual void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct);
	virtual int VKeyToItem(UINT nKey, UINT nIndex);

	// 消息
	afx_msg void OnLbnSelchange();
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);

	// 操作
	void SetIconSize(int nWidth, int nHeight);
	void AddItem(CString lpszItemName, UINT nBitMap);
	void SetSelClr(COLORREF clr);
	void SetBackClr(COLORREF clr);
	void SetTextClr(COLORREF clr);
	void SetCurSel(int nSel);
	int GetCurSel();
	void EnableEdge(BOOL bEnable);
protected:
	virtual void PreSubclassWindow();
	DECLARE_MESSAGE_MAP()

protected:
	CTypedPtrList<CPtrList, CListItem*> m_pItemList;
	COLORREF                            m_clrSel;
	COLORREF                            m_clrBack;
	COLORREF                            m_clrText;           // 选中后的颜色
	BOOL                                m_bIsEdge;
	int                                 m_nCurSel;
	int                                 m_nPreSel;
	int                                 m_nWidth;
	int                                 m_nHeight;
};


