Click here to Skip to main content
Licence CPOL
First Posted 16 Mar 2006
Views 85,566
Bookmarked 64 times

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

By | 9 Apr 2006 | Article
A WTL tree control that supports Windows Vista style selection and multiple selection.

Introduction

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
)

Description

Draw item selection themed.

Parameters

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

Description

Turns on/off multiple selection.

Parameters

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

Description

Retrieves a list of selected tree items.

Parameters

  • aSelectedItems - Reference to an array of HTREEITEM.

Finally

Any comments or suggestions are welcome.

History

  • 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.

License

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

About the Author

AlanW



United Kingdom United Kingdom

Member

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++ MFC, however I'm slowly being dragged, kicking and screaming into the world of C# and .NET (with a brief pitstop at WTL). He lives in the UK with his beautiful wife, daughter and son and enjoys climbing mountains and kayaking in his spare time (which isn't much).

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
Question不能用啊??? Pinmemberzhangjingfei0:52 21 Jan '10  
GeneralOnLButtonUp is not called correctly PinmemberJinXu5:15 24 Apr '08  
Generalfatal error RC1015: cannot open include file 'atlres.h'. Pinmemberaditya raut15:58 18 Sep '07  
QuestionVC6 Pinmembertoddma9:54 26 Jun '07  
AnswerRe: VC6 Pinmembertoddma9:56 26 Jun '07  
GeneralMake the tree items editable Pinmembershaohao5:52 5 Aug '06  
GeneralFixes for keeping selection when clicking expand and collapse and setting background color PinmemberJ Chris Davies7:44 19 Apr '06  
QuestionIt's very nice , but have MFC version ? Pinmemberjxlixiaoqing23:36 17 Apr '06  
GeneralDisplay problem Pinmemberyongshuan shi20:35 13 Apr '06  
GeneralLooks great, but ... Pinmember_oti14:34 3 Apr '06  
GeneralRe: Looks great, but ... PinmemberAlanW22:43 9 Apr '06  
Generalgreat work but I find a bug! Pinmemberlihezhao5:11 17 Mar '06  
GeneralRe: great work but I find a bug! PinmemberAlanW5:32 17 Mar '06  
GeneralATLApp Error PinmemberSreekanth Muralidharan2:48 17 Mar '06  
GeneralRe: ATLApp Error PinmemberUrquan Master6:45 17 Mar '06  
GeneralRe: ATLApp Error PinmemberUrquan Master7:13 17 Mar '06  
GeneralRe: ATLApp Error PinmemberAlanW9:26 17 Mar '06  

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
Web02 | 2.5.120517.1 | Last Updated 10 Apr 2006
Article Copyright 2006 by AlanW
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid