Click here to Skip to main content
15,892,746 members
Articles / Desktop Programming / MFC

Changing Row Height in an owner drawn Control

Rate me:
Please Sign up or sign in to vote.
4.89/5 (25 votes)
8 Nov 2001CPOL4 min read 360.1K   6.7K   88  
Changing the Row Height in an owner drawn List View Control
// MultilineView.cpp : implementation of the CMultilineView class
//

#include "stdafx.h"
#include "Multiline.h"

#include "MultilineDoc.h"
#include "MultilineView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMultilineView

IMPLEMENT_DYNCREATE(CMultilineView, CFormView)

BEGIN_MESSAGE_MAP(CMultilineView, CFormView)
	//{{AFX_MSG_MAP(CMultilineView)
	ON_BN_CLICKED(ID_POPULATE, OnPopulate)
	ON_BN_CLICKED(ID_OK, OnOk)
	//}}AFX_MSG_MAP
	// Standard printing commands
	ON_COMMAND(ID_FILE_PRINT, CFormView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CFormView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CFormView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CMultilineView construction/destruction

CMultilineView::CMultilineView()
	: CFormView(CMultilineView::IDD)
{
	//{{AFX_DATA_INIT(CMultilineView)
	//}}AFX_DATA_INIT
	// TODO: add construction code here

}

CMultilineView::~CMultilineView()
{
}

void CMultilineView::DoDataExchange(CDataExchange* pDX)
{
	CFormView::DoDataExchange(pDX);
	//{{AFX_DATA_MAP(CMultilineView)
	//}}AFX_DATA_MAP
}

BOOL CMultilineView::PreCreateWindow(CREATESTRUCT& cs)
{
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return CFormView::PreCreateWindow(cs);
}

void CMultilineView::OnInitialUpdate()
{
	CFormView::OnInitialUpdate();
	GetParentFrame()->RecalcLayout();
	ResizeParentToFit();

	m_ListCtrl.SubclassDlgItem(IDC_LIST, this) ;
	m_ListCtrl.SetNoOfLinesPerRow(2) ;
	m_ListCtrl.SetNoOfColumns(3) ;
	m_ListCtrl.SetNoOfRows(2) ;
	m_ListCtrl.OnInitialUpdate() ;
}

/////////////////////////////////////////////////////////////////////////////
// CMultilineView printing

BOOL CMultilineView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// default preparation
	return DoPreparePrinting(pInfo);
}

void CMultilineView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add extra initialization before printing
}

void CMultilineView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// TODO: add cleanup after printing
}

void CMultilineView::OnPrint(CDC* pDC, CPrintInfo* /*pInfo*/)
{
	// TODO: add customized printing code here
}

/////////////////////////////////////////////////////////////////////////////
// CMultilineView diagnostics

#ifdef _DEBUG
void CMultilineView::AssertValid() const
{
	CFormView::AssertValid();
}

void CMultilineView::Dump(CDumpContext& dc) const
{
	CFormView::Dump(dc);
}

CMultilineDoc* CMultilineView::GetDocument() // non-debug version is inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CMultilineDoc)));
	return (CMultilineDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMultilineView message handlers

void CMultilineView::OnPopulate() 
{
	// TODO: Add your control notification handler code here
	
}

void CMultilineView::OnOk() 
{
	// TODO: Add your control notification handler code here
	
}

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
Chief Technology Officer Zeta Software GmbH
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.

➡️ Give me a tip 🙂

In his free time, he does climbing, running and mountain biking. In 2012 he became a father of a cute boy and in 2014 of an awesome girl.

Some cool, free software from us:

Windows 10 Ereignisanzeige  
German Developer Community  
Free Test Management Software - Intuitive, competitive, Test Plans.  
Homepage erstellen - Intuitive, very easy to use.  
Offline-Homepage-Baukasten

Comments and Discussions