Click here to Skip to main content
11,635,788 members (74,835 online)
Click here to Skip to main content
Add your own
alternative version

Changing Row Height in an owner drawn Control

, 8 Nov 2001 CPOL 273.8K 5.2K 84
Changing the Row Height in an owner drawn List View Control
multiline.zip
multiline
Debug
Multiline.exe
Multiline.clw
Multiline.dsp
Multiline.dsw
Multiline.opt
Multiline.plg
res
Multiline.ico
MultilineDoc.ico
Toolbar.bmp
#if !defined(AFX_LISTCTRLEX_H__30509656_B8A5_11D5_8CEB_00E098800D6B__INCLUDED_)
#define AFX_LISTCTRLEX_H__30509656_B8A5_11D5_8CEB_00E098800D6B__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// ListCtrlEx.h : header file
//
#include "HeaderCtrlEx.h"
/////////////////////////////////////////////////////////////////////////////
// CListCtrlEx window


static _TCHAR *_gszColumnLabel[4] =
{
	_T("Color\nName"), _T("Red\nColor"), _T("Blue\nColor"), _T("Black\nColor")
};


static int _gnColumnWidth[4] =
{
	150, 100, 150, 80
};


static int _gnColumnFmt[4] =
{
	LVCFMT_LEFT, LVCFMT_RIGHT, LVCFMT_RIGHT
};


static _TCHAR *_gszItem[2][4] =
{
	_T("Yellow\nY"),  _T("255\n255"), _T("30"), _T("50"),
	_T("Red\nR"),     _T("255"), _T("30"), _T("50") 
};

class CListCtrlEx : public CListCtrl
{
// Construction
public:
	CListCtrlEx();

// Attributes
public:
	int		m_nLinesPerRow;	
	int     m_nColumns, m_nRows ;

	CFont			m_NewListFont;
	CHeaderCtrlEx	m_HeaderCtrl ;

	void OnInitialUpdate() ;
	void DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct) ;

	void SetNoOfLinesPerRow(int n)  { m_nLinesPerRow = n ; }
	void SetNoOfColumns(int n=1)	{ m_nColumns = n ; }
	void SetNoOfRows(int n=0)		{ m_nRows = n ; }

	afx_msg LRESULT	OnSetFont(WPARAM wParam, LPARAM lParam);
	afx_msg void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);

// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CListCtrlEx)
	//}}AFX_VIRTUAL

// Implementation
public:
	virtual ~CListCtrlEx();

	// Generated message map functions
protected:
	//{{AFX_MSG(CListCtrlEx)
	afx_msg void OnMeasureItem(int nIDCtl, LPMEASUREITEMSTRUCT lpMeasureItemStruct);
	//}}AFX_MSG

	DECLARE_MESSAGE_MAP()
};

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

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

#endif // !defined(AFX_LISTCTRLEX_H__30509656_B8A5_11D5_8CEB_00E098800D6B__INCLUDED_)

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)

Share

About the Author

Uwe Keim
Chief Technology Officer Zeta Producer Desktop CMS
Germany Germany
Uwe does programming since 1989 with experiences in Assembler, C++, MFC and lots of web- and database stuff and now uses ASP.NET and C# extensively, too. He has also teached programming to students at the local university.

In his free time, he does climbing, running and mountain biking. Recently he became a father of a cute boy.

Some cool, free software from us:

German Developer Community  
Free Test Management Software - Intuitive, competitive, Test Plans. Download now!  
Homepage erstellen - Intuitive, very easy to use. Download now!  
Send large Files online for free by Email
Offline-Homepage-Baukasten

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150728.1 | Last Updated 9 Nov 2001
Article Copyright 2001 by Uwe Keim
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid