Click here to Skip to main content
11,925,730 members (60,940 online)
Click here to Skip to main content
Add your own
alternative version


161 bookmarked

A Tree List Control

, 19 Sep 2002
Rate this:
Please Sign up or sign in to vote.
A Tree List Control
<!-- Add the rest of your HTML here -->


This is a class derived from CWnd class. It's a tree control with a list.


Below are some of the many features that CTreeListCtrl has:

  • Compatible with CTreeCtrl & CListCtrl
  • Header drag & drop
  • Drag & drop between CTreeListCtrl
  • Transparent drag window with Alpha blend
  • Double colors of list
  • Background image
  • Check box support
  • Lock box support
  • Embedded modified controls
  • No more in future

Snapshot 1

Snapshot 2

How to use it

Add this string into stdafx.h
#include "..\\TurboDLL\\xTurboDll.h"

Define your controls

class CMyTreeListCtrl : public CTreeListCtrl  
  virtual ~CMyTreeListCtrl();

  afx_msg void OnExpanding(NMHDR* pNMHDR, LRESULT* pResult);
  afx_msg void OnExpanded(NMHDR* pNMHDR, LRESULT* pResult);
  afx_msg void OnUpdating(NMHDR* pNMHDR, LRESULT* pResult);
  afx_msg void OnUpdated(NMHDR* pNMHDR, LRESULT* pResult);
  afx_msg void OnBeginDrag(NMHDR* pNMHDR, LRESULT* pResult);
  afx_msg void OnDragEnter(NMHDR* pNMHDR, LRESULT* pResult);
  afx_msg void OnDragLeave(NMHDR* pNMHDR, LRESULT* pResult);
  afx_msg void OnDragOver(NMHDR* pNMHDR, LRESULT* pResult);
  afx_msg void OnDrop(NMHDR* pNMHDR, LRESULT* pResult);


Use your controls

class CTurboDragDlg : public CDialog
// Construction
  CTurboDragDlg(CWnd* pParent = NULL);   // standard constructor
  CImageList  m_ImageList;
  CMyTreeListCtrl  m_tree1;
  CMyTreeListCtrl m_tree2;

  // TODO: Add extra initialization here
  m_ImageList.Create( IDB_BITMAP_TREE, 16, 4, 0xFF00FF );

  CRect rect;
  rect.DeflateRect( 5, 5, 5, 5 );

  CRect left;
  left = rect;
  left.right = ( rect.left + rect.right ) / 2;

  CRect right;
  right = rect;
  right.left = ( rect.left + rect.right ) / 2;

  m_tree1.Create( 0x50810000, left, this, 0 );
  m_tree2.Create( 0x50810000, right, this, 1 );

        // Add other initialize code here
        return TRUE;  // return TRUE unless you set the focus to a control
  // EXCEPTION: OCX Property Pages should return FALSE

Then use it freely.


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

Web Developer
China China
He is a Visual C++ developer, MCSE
He has been programming in C/C++ for 7 years, Visual C++ with MFC for 5 years and RDBMS: Oracle, MS SQL for 5 years

You may also be interested in...

Comments and Discussions

GeneralMy vote of 5 Pin
Member 94178232-Sep-14 0:48
memberMember 94178232-Sep-14 0:48 
QuestionDragging problem.... Pin
임건택27-Jun-14 17:37
member임건택27-Jun-14 17:37 
AnswerRe: Dragging problem.... Pin
xjianguo15-Oct-15 21:48
memberxjianguo15-Oct-15 21:48 
GeneralMy vote of 5 Pin
mxs8109-Aug-13 19:30
membermxs8109-Aug-13 19:30 
QuestionHow to convert the project to "Use MFC in a Static Library"? Pin
thelastphoenix25-Oct-11 0:45
memberthelastphoenix25-Oct-11 0:45 
GeneralMy vote of 5 Pin
Member 75250316-Sep-11 0:56
memberMember 75250316-Sep-11 0:56 
GeneralUnable to Edit the columns. Pin
Mahadev HK4-May-11 16:41
memberMahadev HK4-May-11 16:41 
GeneralRe: Unable to Edit the columns. Pin
Modal sun20-Sep-11 16:30
memberModal sun20-Sep-11 16:30 
GeneralRe: Unable to Edit the columns. Pin
thelastphoenix16-Nov-11 16:42
memberthelastphoenix16-Nov-11 16:42 
GeneralTuroboDll behaviour in Windows Vista or Windows 7 Pin
Member 115045326-Oct-10 23:38
memberMember 115045326-Oct-10 23:38 
Questionhow to add combobox items Pin
Sakhalean3-Aug-10 22:34
memberSakhalean3-Aug-10 22:34 
AnswerRe: how to add combobox items Pin
Member 115045326-Oct-10 23:54
memberMember 115045326-Oct-10 23:54 
I think Sakhalean has solved the problem in meantime, but I give a hint, for all future readers too:
Using tree list items a combo box is easy.

1. Setting the col to TLM_MODIFY
2. Set the Items text with '|' separator
CString sAllItems = 'Item1|Item2'
sAllItems = sAllItems + '|'
sAllItems = sAllItems + 'Item3';
YOUR_TREELIST_CONTROL.SetItemText(pItem, sAllItems, iCol);
3. Choose a prefered item text
YOUR_TREELIST_CONTROL.SetColumnDefaultText (iCol, 'Item1');

That should work,
Good luck

Marko Winter
GeneralRe: how to add combobox items Pin
Sakhalean27-Oct-10 18:42
memberSakhalean27-Oct-10 18:42 
GeneralRe: how to add combobox items Pin
dd_dzs10-Apr-11 23:05
memberdd_dzs10-Apr-11 23:05 
QuestionThe tree list control Pin
YeMeGe20-May-10 12:24
memberYeMeGe20-May-10 12:24 
QuestionHow to solve Bug using ComboBox Pin
uara8229-Oct-09 17:41
memberuara8229-Oct-09 17:41 
General"A required resource was unavailable" Pin
Naryoril1-Sep-09 2:19
memberNaryoril1-Sep-09 2:19 
Generalfind a bug Pin
7817537914-May-09 22:24
member7817537914-May-09 22:24 
GeneralMultiline text inNode Pin
jatin dave20-Jan-09 22:48
memberjatin dave20-Jan-09 22:48 
GeneralCrash in CancelControl() on 64 bit platforms. Pin
Member 431310519-Dec-08 3:15
memberMember 431310519-Dec-08 3:15 
QuestionCrash in CancelModify - after ESCAPE key Pin
Member 115045313-Nov-08 0:30
memberMember 115045313-Nov-08 0:30 
GeneralFind a text and highlight Pin
mohadeb14-Oct-08 4:22
membermohadeb14-Oct-08 4:22 
Question跪求,老大这个怎么编译Release版本? Pin
tuhaitao9-Jun-08 20:07
membertuhaitao9-Jun-08 20:07 
AnswerRe: 跪求,老大这个怎么编译Release版本? Pin
cnZhangcm26-Mar-09 23:21
membercnZhangcm26-Mar-09 23:21 
GeneralRe: 跪求,老大这个怎么编译Release版本? Pin
spaceknight7-Jul-09 18:43
memberspaceknight7-Jul-09 18:43 
GeneralRe: 跪求,老大这个怎么编译Release版本? Pin
maicoye22-Jul-09 22:59
membermaicoye22-Jul-09 22:59 
QuestionCrashed when I Expand All the Items in Release Version Pin
mconstor27-Apr-08 20:36
membermconstor27-Apr-08 20:36 
AnswerRe: Crashed when I Expand All the Items in Release Version Pin
mconstor31-May-08 19:26
membermconstor31-May-08 19:26 
Generaltotally useles code for existing control Pin
kilt26-Apr-08 6:00
memberkilt26-Apr-08 6:00 
GeneralRe: totally useles code for existing control Pin
Kochise1-Oct-08 7:51
memberKochise1-Oct-08 7:51 
Questionthe Combobox control cannot be dropdown when use together with TreeListCtrl in a same dialogbox [modified] Pin
doublestone8-Apr-08 3:51
memberdoublestone8-Apr-08 3:51 
QuestionCan we use the code freely? Pin
Member 461932710-Dec-07 15:12
memberMember 461932710-Dec-07 15:12 
QuestionCan you not show expansion boxes on leaf items? Pin
Steve_Harris15-Nov-07 0:45
memberSteve_Harris15-Nov-07 0:45 
AnswerRe: Can you not show expansion boxes on leaf items? Pin
ahrdmy harmy8-Mar-09 21:52
memberahrdmy harmy8-Mar-09 21:52 
QuestionHow to include TurboDLL staticaly into a project [modified] Pin
Kochise9-May-07 22:16
memberKochise9-May-07 22:16 
AnswerRe: How to include TurboDLL staticaly into a project Pin
net_id1-Jan-09 20:58
membernet_id1-Jan-09 20:58 
Generalin-list editing of subitem Pin
Mike Eriksson13-Apr-07 0:49
memberMike Eriksson13-Apr-07 0:49 
GeneralRe: in-list editing of subitem Pin
Mike Eriksson13-Apr-07 22:53
memberMike Eriksson13-Apr-07 22:53 
GeneralRe: in-list editing of subitem Pin
Mr.SeYeu6-Jul-08 17:11
memberMr.SeYeu6-Jul-08 17:11 
QuestionSorting? Pin
LittleIan3-Apr-07 2:02
memberLittleIan3-Apr-07 2:02 
QuestionSortChildren Pin
Jordan Walters2-Apr-07 13:24
memberJordan Walters2-Apr-07 13:24 
GeneralCan't include in my .NET 2003 project!! Pin
Khanafer24-Nov-06 7:20
memberKhanafer24-Nov-06 7:20 
QuestionHow to implementation Print list item? Pin
tangversion15-Oct-06 21:33
membertangversion15-Oct-06 21:33 
Generali can't add it in control(VB code) Pin
Phan Thanh Lam8-Oct-06 18:56
memberPhan Thanh Lam8-Oct-06 18:56 
GeneralRe: i can't add it in control(VB code) Pin
Christian Graus8-Oct-06 20:05
staffChristian Graus8-Oct-06 20:05 
QuestionSet color in subitems Pin
catia_wapf3-Aug-06 3:20
membercatia_wapf3-Aug-06 3:20 
AnswerRe: Set color in subitems Pin
tangversion15-Oct-06 21:29
membertangversion15-Oct-06 21:29 
GeneralCan´t delete columns... Pin
vertex_x17-Apr-06 2:44
membervertex_x17-Apr-06 2:44 
QuestionHow to print? Pin
tangversion27-Mar-06 20:05
membertangversion27-Mar-06 20:05 
GeneralLot of Flicker when Resizing Pin
Bagul Buva8-Mar-06 12:58
memberBagul Buva8-Mar-06 12:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.151126.1 | Last Updated 20 Sep 2002
Article Copyright 2002 by TigerX
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid