Click here to Skip to main content
Licence 
First Posted 19 Sep 2002
Views 445,319
Bookmarked 135 times

A Tree List Control

By | 19 Sep 2002 | Article
A Tree List Control

Introduction

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

Features

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  
{
public:
  CMyTreeListCtrl();
  virtual ~CMyTreeListCtrl();

protected:
  //{{AFX_MSG(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);
  //}}AFX_MSG

  DECLARE_MESSAGE_MAP()
};

Use your controls

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

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

  CRect rect;
  GetClientRect(&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.

License

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

TigerX

Web Developer

China China

Member

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

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
QuestionHow to convert the project to "Use MFC in a Static Library"? Pinmemberthelastphoenix23:45 24 Oct '11  
GeneralMy vote of 5 PinmemberMember 752503123:56 5 Sep '11  
GeneralUnable to Edit the columns. PinmemberMahadev HK15:41 4 May '11  
GeneralRe: Unable to Edit the columns. PinmemberModal sun15:30 20 Sep '11  
GeneralRe: Unable to Edit the columns. Pinmemberthelastphoenix15:42 16 Nov '11  
GeneralTuroboDll behaviour in Windows Vista or Windows 7 PinmemberMember 115045322:38 26 Oct '10  
Questionhow to add combobox items PinmemberSakhalean21:34 3 Aug '10  
AnswerRe: how to add combobox items PinmemberMember 115045322:54 26 Oct '10  
GeneralRe: how to add combobox items PinmemberSakhalean17:42 27 Oct '10  
GeneralRe: how to add combobox items Pinmemberdd_dzs22:05 10 Apr '11  
QuestionThe tree list control PinmemberYeMeGe11:24 20 May '10  
QuestionHow to solve Bug using ComboBox Pinmemberuara8216:41 29 Oct '09  
General"A required resource was unavailable" PinmemberNaryoril1:19 1 Sep '09  
Generalfind a bug Pinmember7817537921:24 14 May '09  
GeneralMultiline text inNode Pinmemberjatin dave21:48 20 Jan '09  
GeneralCrash in CancelControl() on 64 bit platforms. PinmemberMember 43131052:15 19 Dec '08  
QuestionCrash in CancelModify - after ESCAPE key PinmemberMember 115045323:30 12 Nov '08  
GeneralFind a text and highlight Pinmembermohadeb3:22 14 Oct '08  
Question跪求,老大这个怎么编译Release版本? Pinmembertuhaitao19:07 9 Jun '08  
AnswerRe: 跪求,老大这个怎么编译Release版本? PinmembercnZhangcm22:21 26 Mar '09  
GeneralRe: 跪求,老大这个怎么编译Release版本? Pinmemberspaceknight17:43 7 Jul '09  
GeneralRe: 跪求,老大这个怎么编译Release版本? Pinmembermaicoye21:59 22 Jul '09  
QuestionCrashed when I Expand All the Items in Release Version Pinmembermconstor19:36 27 Apr '08  
AnswerRe: Crashed when I Expand All the Items in Release Version Pinmembermconstor18:26 31 May '08  
I Get it at last:
The Layout() is contained in OnSize(), but the SetAllScroll() in Layout() may cause the OnSize(), so it goes to endless Cyc;
 
Solution:
Move the two SetAllScroll() funtions in Layout() to OnSize().
Generaltotally useles code for existing control Pinmemberkilt5:00 26 Apr '08  

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

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

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