#if !defined(AFX_DRAGDROPLISTCTRL_H__17F6D56D_591C_4319_B0EB_9D6D9B45BC79__INCLUDED_)
#define AFX_DRAGDROPLISTCTRL_H__17F6D56D_591C_4319_B0EB_9D6D9B45BC79__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif 

class CDragDropListCtrl : public CListCtrl
{
protected:
	// Ҫ���϶���1�����������������;
	CDWordArray			m_anDragIndexes;	
	// ��ǰ���϶����滻��������;
	int					m_nDropIndex;
	// ��ǰ�϶������ͣ��ѡ���ϵ�����
	int					m_nCurIndex;
	// �϶�ʱ��ͼ��;
	CImageList*			m_pDragImage;		
	// ��һ������;
	int					m_nPrevDropIndex;	
	// ��һ��״̬;
	UINT				m_uPrevDropState;	
	DWORD				m_dwStyle;

	// �����϶�����ʼ����;
	CPoint m_ptStart;
	// ��ǰ�ƶ��������;
	CPoint m_ptCurr;
	// �ƶ���ʼ���뵱ǰ�������������;
	void MoveDragItem(CPoint ptMove);


	enum EScrollDirection
	{
		scrollNull,
		scrollUp,
		scrollDown
	};
	EScrollDirection	m_ScrollDirection;
	UINT				m_uScrollTimer;

public:
	CDragDropListCtrl();
	bool IsDragging() const { return m_pDragImage != NULL; }
	CDWordArray* GetDragIndexes(){return &m_anDragIndexes;}
	int	GetDragSelIndex(){return m_nCurIndex;}

public:

	virtual ~CDragDropListCtrl();

protected:
	void DropItem();
	void DropItem(CPoint pt);
	void RestorePrevDropItemState();
	void UpdateSelection(int nDropIndex);
	void SetScrollTimer(EScrollDirection ScrollDirection);
	void KillScrollTimer();
	CImageList* CreateDragImageEx(LPPOINT lpPoint);

	// ��ȡ������Ӧ�������;
	int GetPtItemIndex(CPoint pt);
	
protected:
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnTimer(UINT nIDEvent);

	DECLARE_MESSAGE_MAP()
};

#endif