Click here to Skip to main content
12,894,930 members (57,602 online)
Click here to Skip to main content
Add your own
alternative version


74 bookmarked
Posted 16 Mar 2006

TreeCtrl - A WTL tree control with Windows Vista style item selection

, 9 Apr 2006 CPOL
Rate this:
Please Sign up or sign in to vote.
A WTL tree control that supports Windows Vista style selection and multiple selection.


After quite a few requests, I thought I'd post this tree control that uses a similar selection drawing style to the list control I posted here: ListCtrl - A WTL list control with Windows Vista style item selection. For an added bonus, I've also included support for multiple-selection.

How to use CTreeCtrl

Simply use the tree control as you would the normal CTreeViewCtrl, however there are a couple of functions required to activate and retrieve multiple selections:

void ShowThemed( 
    BOOL bShowThemed = TRUE


Draw item selection themed.


  • bShowThemed - TRUE = Draw themed selection; FALSE = Classic mode.
void SetMultipleSelect( 
       BOOL bMultipleSelect


Turns on/off multiple selection.


  • bMultipleSelect - TRUE = Turn on multiple select.
void GetSelectedItems( 
    CSimpleArray < HTREEITEM >& aSelectedItems


Retrieves a list of selected tree items.


  • aSelectedItems - Reference to an array of HTREEITEM.


Any comments or suggestions are welcome.


  • 16th March, 2006: 1.0
    • First release.
  • 20th March, 2006: 1.1
    • Small bug fix for VS2005.
  • 5th April, 2006: 1.2
    • Corrected problems with multiple select and checkboxes - many thanks to Phil C.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

United Kingdom United Kingdom
Alan has been developing applications for a very long time (~10 years), but he's not bitter about this at all. My main area of expertise is C++. He lives in Sweden with his beautiful wife, daughter and son and enjoys climbing mountains and kayaking in his spare time (which isn't much).

You may also be interested in...


Comments and Discussions

GeneralFixes for keeping selection when clicking expand and collapse and setting background color Pin
J Chris Davies19-Apr-06 7:44
memberJ Chris Davies19-Apr-06 7:44 
QuestionIt's very nice , but have MFC version ? Pin
jxlixiaoqing17-Apr-06 23:36
memberjxlixiaoqing17-Apr-06 23:36 
GeneralDisplay problem Pin
yongshuan shi13-Apr-06 20:35
memberyongshuan shi13-Apr-06 20:35 
GeneralLooks great, but ... Pin
_oti3-Apr-06 14:34
member_oti3-Apr-06 14:34 
GeneralRe: Looks great, but ... Pin
AlanW9-Apr-06 22:43
memberAlanW9-Apr-06 22:43 
Generalgreat work but I find a bug! Pin
lihezhao17-Mar-06 5:11
memberlihezhao17-Mar-06 5:11 
GeneralRe: great work but I find a bug! Pin
AlanW17-Mar-06 5:32
memberAlanW17-Mar-06 5:32 
GeneralATLApp Error Pin
Sreekanth Muralidharan17-Mar-06 2:48
memberSreekanth Muralidharan17-Mar-06 2:48 
GeneralRe: ATLApp Error Pin
Urquan Master17-Mar-06 6:45
memberUrquan Master17-Mar-06 6:45 
GeneralRe: ATLApp Error Pin
Urquan Master17-Mar-06 7:13
memberUrquan Master17-Mar-06 7:13 
GeneralRe: ATLApp Error Pin
AlanW17-Mar-06 9:26
memberAlanW17-Mar-06 9:26 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170424.1 | Last Updated 10 Apr 2006
Article Copyright 2006 by AlanW
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid