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

Versatile Tree Control

, 18 Feb 2013
Tree control with custom checkbox with several other features.
customtreectrl.zip
CustomTreeCtrlCode.zip
CustomTreeCtrl
1.bmp
2.bmp
CustomTreeCtrl.aps
CustomTreeCtrl.clw
CustomTreeCtrl.dsp
CustomTreeCtrl.dsw
CustomTreeCtrl.opt
CustomTreeCtrl.plg
CustomTreeCtrl.suo
CustomTreeCtrl.vcproj.DEPIND01.nuvsoft31.user
nodrop.cur
res
bitmap1.bmp
bitmap_c.bmp
bitmap_d.bmp
bitmap_e.bmp
bitmap_f.bmp
bitmap_h.bmp
bitmap_m.bmp
bitmap_u.bmp
bmp00003.bmp
bmp00004.bmp
bmp00005.bmp
bmp00006.bmp
bmp00007.bmp
bmp00008.bmp
bmp00009.bmp
bmp00010.bmp
CustomTreeCtrl.ico
icon1.ico
// CustomTreeCtrlDlg.h : header file
//

#if !defined(AFX_CUSTOMTREECTRLDLG_H__A9DD5E95_0B84_43F9_96D8_4B3B155A4DD8__INCLUDED_)
#define AFX_CUSTOMTREECTRLDLG_H__A9DD5E95_0B84_43F9_96D8_4B3B155A4DD8__INCLUDED_

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

#include "CCVersatileTreeCtrl.h"

//************************************************

typedef struct __PROJECTMEMBER
{
	__PROJECTMEMBER()
	{
		m_pCustomData = NULL;
	}
	~__PROJECTMEMBER();
	
	//Name of the project member
	CString  m_sName;

	//Custom data associated with the  member
	PCUSTOMITEMDATA		m_pCustomData;
	
}PROJECTMEMBER,*PPROJECTMEMBER;

//************************************************

typedef struct __PROJECTLEAD
{
	__PROJECTLEAD()
	{
		m_projMembers = NULL;
		m_pCustomData = NULL;
	}
	~__PROJECTLEAD();

	//Name of the lead
	CString m_sName;

	//Number of Project members under the lead
	int		m_nProjmembers;

	//Custom data associated with the lead
	PCUSTOMITEMDATA		m_pCustomData;

	//Project members under the lead
	PPROJECTMEMBER	m_projMembers;

}PROJECTLEAD,*PPROJECTLEAD;

//************************************************
typedef struct __PROJECT
{
	__PROJECT()
	{
		m_projLead		= NULL;
		m_pCustomData = NULL;
	}
	~__PROJECT();


	CString m_sTitle;
	int     m_nProjLeads;
	PPROJECTLEAD  m_projLead;
	PCUSTOMITEMDATA		m_pCustomData;

}PROJECT,*PPROJECT;


/////////////////////////////////////////////////////////////////////////////
// CCustomTreeCtrlDlg dialog

class CCustomTreeCtrlDlg : public CDialog
{
// Construction
public:
	CCustomTreeCtrlDlg(CWnd* pParent = NULL);	// standard constructor

	~CCustomTreeCtrlDlg();

// Dialog Data
	//{{AFX_DATA(CCustomTreeCtrlDlg)
	enum { IDD = IDD_CUSTOMTREECTRL_DIALOG };
	CVersatileTreeCtrl	m_ctrlTree;
	CListBox	m_ctrlListSelected;
	CListBox	m_ctrlLstChecked;
	//}}AFX_DATA

	//Project members working with the project leads
	PPROJECTMEMBER	m_pGeForceProjectMembers,m_pQuadroProjectMembers ;

	//Project leads of the projects
	PPROJECTLEAD	m_pGeForceProjectLead,m_pQuadroProjectLead ;

	//Project details
	PPROJECT		m_pGeForceProject,m_pQuadroProject;


	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CCustomTreeCtrlDlg)
	protected:
	virtual void DoDataExchange(CDataExchange* pDX);	// DDX/DDV support
	//}}AFX_VIRTUAL

	void InitializeTree();

	//Insert the project
	void InserProject(PPROJECT pProj,HTREEITEM hRoot );

	//Insert the project lead
	void InserProjectLead(PPROJECTLEAD pProjLead,HTREEITEM hProj );

	//Insert the project members
	void InsertProjectMembers( PPROJECTMEMBER pProjMem,HTREEITEM hProjLead );

// Implementation
protected:
	HICON m_hIcon;

	// Generated message map functions
	//{{AFX_MSG(CCustomTreeCtrlDlg)
	virtual BOOL OnInitDialog();
	virtual void OnOK();
	afx_msg void OnSysCommand(UINT nID, LPARAM lParam);
	afx_msg void OnPaint();
	afx_msg HCURSOR OnQueryDragIcon();
	afx_msg LRESULT OnTreeSelectionChanged(WPARAM wparam,LPARAM lparam );
	afx_msg LRESULT OnTreeItemChecked(WPARAM wparam,LPARAM lparam );		
	afx_msg void OnBolditem();
	afx_msg void OnNormalItem();
	afx_msg void OnInsertAfter();
	afx_msg void OnInsertBefore();
	afx_msg void OnChangeColor();
	afx_msg void OnDelete();
	afx_msg void OnAddChkBox();
	afx_msg void OnRemoveChkBox();
	afx_msg void OnDisable( );
	afx_msg void OnEnable( );
	afx_msg void OnInitMenuPopup(CMenu* pMenu, UINT nIndex, BOOL bSysMenu) ;	
	afx_msg void OnExpandTree( );
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

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

#endif // !defined(AFX_CUSTOMTREECTRLDLG_H__A9DD5E95_0B84_43F9_96D8_4B3B155A4DD8__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)

About the Author

syed_babu
Software Developer
India India
I'm working as Senior software Engineer since 7 years and interested in MFC and COM programming.

| Advertise | Privacy | Mobile
Web04 | 2.8.140721.1 | Last Updated 19 Feb 2013
Article Copyright 2013 by syed_babu
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid