Click here to Skip to main content
Click here to Skip to main content

A Tree List Control

By , 19 Sep 2002
 

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.
Search this forum  
    Spacing  Noise  Layout  Per page   
Questionhow to add combobox itemsmemberSakhalean3 Aug '10 - 21:34 
I want to add combo box items to the list control
How to add items to combobox
and where to add combo box items.
 
Pls help me.
AnswerRe: how to add combobox itemsmemberMember 115045326 Oct '10 - 22:54 
Hi!
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
YOUR_TREELIST_CONTROL.ColumnModify (iCol, TLM_COMBO);
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 itemsmemberSakhalean27 Oct '10 - 17:42 
Hi,
Thank you very much for the reply.
 
Any have I have solved the problem.
GeneralRe: how to add combobox itemsmemberdd_dzs10 Apr '11 - 22:05 
1 m_ctrStat.SetColumnModify(nCol, TLM_COMBO );
2 m_ctrStat.SetColumnDefaultText(nCol, "xx|mm|ss" );
3 m_ctrStat.SetItemText(pItem, "xx", nCol);

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

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