Tree List Control

The accompanying code is an implementation of a tree view, combined with a list view, for the Windows API. The view is compatible to the tree control of the common controls. It allows the user to set colors, text, and icons for each item separately. An MFC class for the view is also implemented.

Features

  • The window messages are compatible with the tree control of the common controls.
  • Alternating colors are provided for each line.
  • The color, style, and icon could be set for each item separately.
  • An MFC class is also implemented (CTreeCtrl is the base class).
  • An index access is implemented so that you can get the item of a line.

The main source code is in the TreeListWnd.cpp file. The MFC class is in the TreeListCtrl.cpp file.

This demo was written by Anton Zechner.



Downloads

Comments

  • HitTest not working

    Posted by real_skydiver on 03/23/2014 11:49pm

    I receive random HTREEITEM results when I use 'HitTest' in 'OnContextMenu' - but never the one I really clicked on. Without that function the control is pretty useless because a control is supposed to offer interaction between data und user.

    Reply
  • Column width does not update

    Posted by Egon Broquist on 12/17/2012 04:57am

    Trying to change the column width and the column format but it does not work. SetColumnWidth(1,100); // No change col.mask = LVCF_TEXT | LVCF_FMT | LVCF_WIDTH; col.pszText = _T("Test"); col.fmt = LVCFMT_RIGHT; col.cx = 100; SetColumn(1,&col;) // No change

    • Which version did you use

      Posted by AZ on 02/27/2013 08:11am

      Have you used the newest version (1.94) from my homepage: http://members.inode.at/anton.zechner/az/TreeList.en.htm ?

      • Updated to latest version 1.94

        Posted by Egon Broquist on 04/30/2013 06:05am

        But same problem. SetColumn(n,&col;) does not change the header text or alignment.

        • Bus is fixed

          Posted by Anton Zechner on 07/01/2013 07:24am

          I have fixed this bug in the newest version on my homepage: http://members.inode.at/anton.zechner/az/TreeList.en.htm

          Reply
        • bug fixed

          Posted by Anton Zechner on 06/25/2013 01:24pm

          Hello In the version 1.98 on my homepage: http://members.inode.at/anton.zechner/az/TreeList.en.htm the bug is fixed

          Reply
        • buf fixed

          Posted by Anton Zechner on 06/25/2013 01:16pm

          In the version 1.98 i have fixed this problem.

          Reply
        Reply
      Reply
    Reply
  • ATL modification

    Posted by Sergey Kozlov on 04/25/2012 03:25am

    Could you make the same using ATL?

    • human

      Posted by Anton Zechner on 08/30/2012 12:57pm

      Sorry, i am not interrested on ATL, aund i have no time for this

      Reply
    Reply
  • help..

    Posted by ykc7859 on 04/24/2009 01:38am

    How to hide listheader?

    • Look on my homepage

      Posted by xyz007 on 05/22/2009 09:08am

      Hi, you find the actual sources of the control on my homepage http://members.inode.at/anton.zechner/az/TreeList.en.htm Use the extended style TVS_EX_HIDEHEADERS. (see at CTreeListCtrl.chm "Extended Styles")

      Reply
    Reply
  • New bug

    Posted by haoziqi on 12/24/2008 09:37am

    An error occurs when using function InsertItem insert a item after an existing item.

    • Use the actual source code

      Posted by xyz007 on 01/04/2009 10:42am

      Please use the actual on my homepage: http://members.inode.at/anton.zechner/az/TreeList.en.htm

      Reply
    Reply
  • Bug in Vista

    Posted by googlejaps on 12/16/2008 06:41am

    When using the treelist (version from http://members.inode.at /anton.zechner/az/TreeList.htm) the list doesn't update well in Vista. When I collapse and then expand the items in the tree, the text in the 2nd and 3rd columns are not updated right. See the screenshot at: http://jvmeerman.googlepages.com/TreeViewBug.jpg. The right screen shows the tree as it should look like. The left screen shows the tree after collapsing and expanding. I've tested this in XP and in Vista. In XP it works fine, in Vista this problem occurrs. On resize the tree is refreshed and it shows correct again.

    • Reply

      Posted by xyz007 on 01/04/2009 10:45am

      I have posted a new version on my homepage. In this version i can't reproduce this problem on vista. http://members.inode.at/anton.zechner/az/TreeList.en.htm

      Reply
    Reply
  • some modify

    Posted by shixopen on 08/18/2008 04:54am

    my english is very poor.. cry...

    • Thanks

      Posted by xyz007 on 09/01/2008 02:45pm

      Thanks for the hints. I will post it on my homepage.

      Reply
    • some modify

      Posted by shixopen on 08/18/2008 05:11am

      add:
      line 8514:   	case WM_MOUSEWHEEL:
      line 8575:      case WM_HSCROLL:
      line 8539:      case WM_VSCROLL:
      ...
      add:  (for edit can't move)
      if (pData->uEditItem)  return 0;
      
      
      modify:
      line 5260:    return pData->pItemPos[uPos+1];
      --->          return pData->pItemPos[uPos];
      
      line 5373:    return pData->pItemPos[uPos-1];
      --->
      if ( uPos < 2 ) return 0;
      return pData->pItemPos[uPos-2];
      
      when have big image
      line 10197:     sButton.bottom	= sArea.bottom;
      --->            sButton.bottom	= iYpos + pData->iFontHeight;
      
      when pData->uScrollX > 0, "..."error
      line 10211:  if(sArea.left+pEntry->iTextPixels>=sArea.right)
      -->          if(sArea.left+pEntry->iTextPixels >= sArea.right -pData->uScrollX)
      
      line 10215:   iSize  = sArea.right-sArea.left;
      -->           iSize  = sArea.right-pData->uScrollX-sArea.left -2;

      Reply
    Reply
  • Can I use this code in an internal project

    Posted by anuruddha_g on 01/01/2008 11:46pm

    Hi, I was looking for a tree list control to be used in a support tool, which is being used inside my organization. Can I use the source files for my purporse? In a previous comment I found that if one is using this code, the application should be published as well. Does the same apply for my situation? (The tool I intend to use this treelist concentrates highly on software developing practices within the company and I dont see any use of this tool outside the organization even if published.) Thanks

    • In none commecial programms

      Posted by xyz007 on 02/05/2008 07:20am

      Hi You can use it, if you don't sell your programm. In the ohter case you must publish the source of your program. Note: The newes sources are on my homepage. I have fixed some bugs, and new features are implemented. http://members.inode.at/anton.zechner/az/TreeList.htm

      Reply
    Reply
  • Bugs

    Posted by pyabo on 06/19/2007 06:03pm

    Hello, I found 2 bugs: - In TreeListInsertItem when you look to find a new handle for the item you do: for(;;uPos++) { if(uPos>pData->uTreeItemsMax)uPos=1; if(pItems[uPos]==NULL)break; } but uPos should be tested for >= because in the function TreeListGetItem you test: if(uItem>=pData->uTreeItemsMax)return 0; So if there is an item that has exactly the handle equal to uTreeItemsMax you cannot get the data associated to it. - Second: the tooltip window is set as top-level and you see its creation in the application bar. - Another thing: is this control GPL or LGPL license? Thanks, Pablo Yabo

    • I have all fixed

      Posted by xyz007 on 06/29/2007 02:13pm

      Hi Thank you for your hints.
      I have fixed the bugs in TreeListV5.zip, or on my HomePage:
      http://members.inode.at/anton.zechner/az/TreeList.htm

      The code is unter GPL. Comercial users must publish thier code, or make an aggrement with me.

      Reply
    Reply
  • New bug

    Posted by Heyjoe on 05/02/2007 05:26am

    Hi, When Items are deleted, pData->uTreeItemsCount is not update. Could you fixe this bug please Thanx Julien

    Reply
  • Loading, Please Wait ...

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Best-in-Class organizations execute on a strategy that supports the multi-channel nature of customer requests. These leading organizations do not just open up their service infrastructures to accommodate new channels, but also empower their teams to deliver an effective and consistent experience regardless of the channel selected by the customer. This document will highlight the key business capabilities that support a Best-in-Class customer engagement strategy.

  • Live Event Date: September 17, 2014 @ 1:00 p.m. ET / 10:00 a.m. PT Another day, another end-of-support deadline. You've heard enough about the hazards of not migrating to Windows Server 2008 or 2012. What you may not know is that there's plenty in it for you and your business, like increased automation and performance, time-saving technical features, and a lower total cost of ownership. Check out this upcoming eSeminar and join Rich Holmes, Pomeroy's practice director of virtualization, as he discusses the …

Most Popular Programming Stories

More for Developers

Latest Developer Headlines

RSS Feeds