Click here to Skip to main content
15,886,110 members
Articles / Desktop Programming / MFC

CListCtrlExt and CListViewExt controls

Rate me:
Please Sign up or sign in to vote.
4.78/5 (22 votes)
20 Feb 2012CPOL5 min read 82.8K   8.7K   84  
An enhanced list control based on the standard CListCtrl MFC class.
// HeaderCtrlExt.h : interface of the CHeaderCtrlExt class
//
/////////////////////////////////////////////////////////////////////////////

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

extern UINT WM_HDN_ENDDRAG;
// added for Visual 6.xx (lSalters)...
typedef unsigned long ULONG_PTR, *PULONG_PTR;
typedef ULONG_PTR DWORD_PTR, *PDWORD_PTR;

/////////////////////////////////////////////////////////////////////////////
// CHeaderCtrlExt

class CHeaderCtrlExt : public CHeaderCtrl
{
	DECLARE_DYNAMIC(CHeaderCtrlExt)

public:
	class CItemData
	{
	public:
		CItemData(int nWidth, BOOL bRemovable, BOOL bVisible)
		{
			m_nWidth = nWidth;
			m_bVisible = bVisible;
			m_bRemovable = bRemovable;
		}
		int m_nWidth;
		BOOL m_bVisible;
		BOOL m_bRemovable;
	};

public:
	CHeaderCtrlExt();
	virtual ~CHeaderCtrlExt();

	int GetItemWidth(int nIndex);
	int IndexToOrder(int nIndex);
	int FindVisibleItem(int nIndex);
	BOOL SetItemWidth(int nIndex, int nWidth);
	BOOL GetWidthArray(int* piArray, int nCount);
	BOOL SetWidthArray(int nCount, int* piArray);
	DWORD_PTR GetItemData(int nIndex);
	BOOL SetItemData(int nIndex, DWORD_PTR dwData);
	BOOL GetVisibleArray(int* piArray, int nCount);
	BOOL SetVisibleArray(int nCount, int* piArray);
	BOOL GetVisible(int nIndex);
	void SetVisible(int nIndex, BOOL bVisible);
	BOOL GetRemovable(int nIndex);
	void SetRemovable(int nIndex, BOOL bRemovable);
	void ResetItemWidth(int nIndex);
	BOOL SetOrderArray(int nCount, LPINT piArray);
	int GetVisibleItemCount();
	int GetRemovableItemCount();

protected:
	BOOL m_nItemWidth;
	CPoint m_ptDragEnd;
	CPoint m_ptDragMove;
	CPoint m_ptDragStart;
	int m_nDraggingItem;
	BOOL m_bDragFullWindow;

protected:
	void DrawDragDivider();
	void BeginDragDivider();
	int	ItemFromPoint(CPoint point);
	void EndDragDivider(BOOL bSubmit);

protected:
	//{{AFX_MSG(CHeaderCtrlExt)
	afx_msg void OnDestroy();
	afx_msg void OnCaptureChanged(CWnd* pWnd);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
	afx_msg BOOL OnSetCursor(CWnd* pWnd, UINT nHitTest, UINT message);
	//}}AFX_MSG
	afx_msg LRESULT OnHdnEndDrag(WPARAM wParam, LPARAM lParam);
	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Romania Romania
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions