Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Custom drawn vertical tree control

, 14 Oct 2005
A CTreeCtrl derived class which is both: a normal CTreeCtrl or a fully custom drawn vertical tree control.
 * Copyright (C) 2005
 * Doga Arinir
 * Author: Doga Arinir
 * E-Mail:
 * This software is provided 'as-is', without any express or implied
 * warranty.  In no event will the author or the company be held liable 
 * for any damages arising from the use of this software. EXPECT BUGS!
 * You may use this software in compiled form in any way you desire PROVIDING it is
 * not sold for profit without the authors written permission, and providing that this
 * notice and the authors name is included. If the source code in this file is used in 
 * any commercial application then acknowledgement must be made to the author of this file.

#if !defined(AFX_VERTICALTREE1_H__D9ACD532_0DEB_422B_9037_2EC4CCD72144__INCLUDED_)
#define AFX_VERTICALTREE1_H__D9ACD532_0DEB_422B_9037_2EC4CCD72144__INCLUDED_

#pragma warning(disable:4786)

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// VerticalTree1.h : Header-Datei
#include <map>

// Fenster CVerticalTree 
#define BUTTON_SIZE 9
class CVerticalTree : public CTreeCtrl
struct ItemViewport
	ItemViewport(HTREEITEM i) {this->item = i;}
	int cx;
	int cy;
	int x;
	int y;
typedef std::map<HTREEITEM, ItemViewport*> HTREE2VPMAP;
// Konstruktion

// Attribute

	BOOL m_bHasLines;
	BOOL m_bHasButtons;
	BOOL m_bCustomDrawn;
	int m_ItemSpaceX;
	int m_ItemSpaceY;

	CRect m_Rect;
	int   m_OffsetX;
	int   m_OffsetY;
	int   m_XMax;
	int   m_YMax; 

	COLORREF m_LeafTextColor;
	COLORREF m_LeafBkColor;
	COLORREF m_ItemTextColor;
	COLORREF m_ItemBkColor;

	CPen	m_TreeLinePen;
// Operationen
	void SetCustomDrawn(BOOL);
	BOOL GetCustomDrawn();

	//These operations are overwritten. The Problem is that those are non-virtual
	HTREEITEM InsertItem(UINT nMask, LPCTSTR lpszItem, int nImage, int nSelectedImage, UINT nState, UINT nStateMask, LPARAM lParam, HTREEITEM hParent, HTREEITEM hInsertAfter);
	HTREEITEM InsertItem(LPCTSTR lpszItem, int nImage, int nSelectedImage, HTREEITEM hParent = TVI_ROOT, HTREEITEM hInsertAfter = TVI_LAST);
	BOOL DeleteItem(HTREEITEM hItem);
	BOOL DeleteAllItems();

// �berschreibungen
	// Vom Klassen-Assistenten generierte virtuelle Funktions�berschreibungen

// Implementierung
	int GetItemSpaceX();
	void SetItemSpaceX(int);
	int GetItemSpaceY();
	void SetItemSpaceY(int);
	virtual ~CVerticalTree();

	// Generierte Nachrichtenzuordnungsfunktionen
	void ResetScrollbars();
	__forceinline ItemViewport* GetViewport(HTREEITEM hItem);
	void DeleteAllViewportItems();
	void DrawItemText(CDC *pDC, HTREEITEM item, const char *text, int x, int y, int cx, int cy, COLORREF bkcolor,COLORREF txtcolor);
	int DrawItem(CDC *pDC, HTREEITEM, int x, int level = 0);
	void UpdateDimensions();
	afx_msg void OnPaint();
	afx_msg BOOL OnEraseBkgnd(CDC* pDC);
	afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
	afx_msg BOOL OnMouseWheel(UINT nFlags, short zDelta, CPoint pt);
	afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
	afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
	afx_msg void OnMouseMove(UINT nFlags, CPoint point);
	afx_msg void OnSizing(UINT fwSide, LPRECT pRect);
	afx_msg void OnSize(UINT nType, int cx, int cy);



// Microsoft Visual C++ f�gt unmittelbar vor der vorhergehenden Zeile zus�tzliche Deklarationen ein.

#endif // AFX_VERTICALTREE1_H__D9ACD532_0DEB_422B_9037_2EC4CCD72144__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.


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


About the Author

Doga Arinir
Chief Technology Officer W3L
Germany Germany
-Since 1th August 2007: Chief Technology Officer of W3L
-2002/08/01-2007/07/31: PhD student
-1997/10/15-2002/07/31: Studied Electrical Engineering and Computer Science

| Advertise | Privacy | Terms of Use | Mobile
Web03 | 2.8.150123.1 | Last Updated 14 Oct 2005
Article Copyright 2005 by Doga Arinir
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid