Click here to Skip to main content
15,891,372 members
Articles / Desktop Programming / MFC

Expandable List Control to Accept Multilines

Rate me:
Please Sign up or sign in to vote.
4.64/5 (9 votes)
14 Aug 20071 min read 89.6K   4.8K   67  
A derived CListCtrl class that expands its rows when it receives multilines
#pragma once

// CMultiLineListCtrl

class CMultiLineListCtrl : public CListCtrl
{
	DECLARE_DYNAMIC(CMultiLineListCtrl)

public:
	CMultiLineListCtrl();
	virtual ~CMultiLineListCtrl();
	void SetGridColor(COLORREF color); 
	void ShowGrid(bool show);
	void ShowMinimized(bool show);
	void CloseAll();
	BOOL SetBkColor(COLORREF cr);
	int InsertItem(const LVITEM* pItem);
	int InsertItem(int nItem,LPCTSTR lpszItem);
	int InsertItem(int nItem,LPCTSTR lpszItem,int nImage);
	BOOL SetItemText(int nItem,int nSubItem,LPCTSTR lpszText);
protected:
	DECLARE_MESSAGE_MAP()

	COLORREF colorSymbol;
	CPen dot;
	bool m_repeatEvent;
	bool m_skipTextCheck;
	bool m_grid;
	bool m_minimized;
	COLORREF m_gridColor;
	int m_lastSelected;
	int m_selected;
	
	afx_msg void OnCustomDraw(NMHDR* pNMHDR, LRESULT* pResult);
	afx_msg void OnActivate(NMHDR *pNMHDR, LRESULT *pResult);
	afx_msg void OnDblClick(NMHDR *pNMHDR, LRESULT *pResult);
	void CalcNumberOfLines(int nItem, LPCTSTR lpszText, bool insert = true);
	void OpenCloseRow(int row);
};

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


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

Comments and Discussions