Virtual Treeview component

Virtual Treeview with Windows XP styles

Virtual Treeview is a treeview control built from ground up. More than a decade of development made it one of the most flexible and advanced Delphi tree controls available today. Virtual Treeview started off with the claim to improve many aspects of existing solutions and introduced some new technologies and principles which were not available before.

As the name already indicates, this control uses a different paradigm for tree management than other controls of this kind. It does not know anything about the data it manages (except its size), not even the captions of a node. Everything is retrieved from the application via events (or descendants via overridden methods).

Virtual Treeview has been carefully designed and thoroughly tested. The control proved its concept as well as everyday fitness already in many commercial products and freeware projects.

 

The current Version of Virtual Treeview is 5.2.1.

There's a translation of this page to the Serbo-Croatian language done by Jovana Milutinovich.

License:

Virtual Treeview is using a double licensing scheme. You can either choose Mozilla Public License 1.1 (MPL 1.1) or GNU Lesser General Public License.

Note: Virtual Treeview needs Windows XP Theme Manager to compile when used with version 6 (and earlier) of Delphi and Borland C++ Builder! You can disable XP theme support, though, to avoid the need for this extra package. Beginning with Delphi 7 Delphi Gems Themes Services are integral part of the VCL so you do not need the extra Theme Manager package with this or any following version.

Public source code repository and issue tracker

Virtual Treeview is hosted on Google Code , which uses Subversion as SCM. The repository is world-readable and so everybody can get the latest code from there.  Also issues should be reported there.

Installation

Starting with version 5.0 Virtual Treeview no longer comes with an own setup program because there is a set of design and runtime packages for each supported IDE version, which can easily be opened to compile and install the control in the IDE. Virtual Treeview supports the following IDEs (and their associated VCLs):

  • Embacadero's RAD Studio XE - XE4
  • Delphi 2010
  • CBuilder 2010
  • Delphi 2009
  • Delphi 2007
  • BDS 2006
  • Delphi 2005
  • Delphi 7

A list of important features

General
Virtual Treeview as document property editor
  • Virtual Treeview is extremely fast. Adding one million nodes takes only 700 milliseconds* ! This made it the fastest treeview publicly available on the Delphi/BCB market already 10 years ago.
  • Virtual Treeview has a very small memory foot print. by only allocating about 60 bytes per node (in the string tree, the base tree uses only 56 bytes) it is well prepared to hold a million of them.
  • Virtual Treeview is optimized for high speed access. It takes as few as 0.5 seconds to traverse one million nodes* depending on needed validation and node validation states.
  • Multiselection is supported, including constrained selection so that only nodes of a certain initial level can be selected. A lot of effort has been put into the development of effective algorithms e.g. to allow for modifying an already large selection set still interactively.
  • Drawing the entire tree to a bitmap or the printer is supported by the central TBaseVirtualTree.PaintTree method. The messages WM_PRINT and WM_PRINTCLIENT are handled correctly which allow things like drawing a tree into a bitmap (e.g. for layered windows or to implement animated drop down of controls which use VT as drop down control).
  • There is an TBaseVirtualTree.OnHint event to display node specific hints.
  • There is an TBaseVirtualTree.OnGetHelpContext event to retrieve node specific help context IDs. This includes automatic tree and window parent control traversal as is invoked when the user pressed F1
  • There is an TBaseVirtualTree.OnGetPopupMenu event to retrieve node specific popup menus, includes automatic tree traversal.
  • Middle and right mouse buttons can be used in addition to the left button and support everything which is possible with the left button (dragging, selection etc.). These alternative buttons can be switched, of course.
  • A fixed background image can be used in the tree and can be given a certain offset, e.g. to simulate shared backgrounds.
  • Hot style for nodes is supported (just like links in a browser window). A special cursor can be assigned for this task.
  • String trees support socalled static text which appears after a node's caption (in every column) and which can be formatted differently to the caption but cannot be edited, selected etc.
  • An auto span column mode is supported which allows a column to take up more space for its caption if there are empty columns to its right. This avoids clipping of long captions but still allows using multiple columns.
  • A node can be selected in every column (this is switchable) as well as edited, making Virtual Treeview some kind of a grid too. The tabulator key can be used to switch the focus between cells. A special option (toGridExtensions) exist to support grid specific tasks.
  • Nodes can have individual heights and the vertical alignment of a node's images and lines can be adjusted individually.
  • Virtual Treeview exposes its internal states like pending drag or edit events, multi selection or expanding in progress. Using this information an application can optimize its code execution (state updates etc.).
  • Sorting a node is supported via an application defined compare call back. Additionally, a tree can be set to auto sort.
  • Hints can contain multiple lines of text and mirror the alignment and directionality of the node or column they are displayed for. For their animation sliding and alpha blending is available.
  • Incremental search with various options and directions is available too.
  • Auto scrolling of the client area happens when the mouse is near the borders while dragging and draw selecting (multi selection).
  • TBaseVirtualTree.DefaultNodeHeight and TVirtualStringTree.DefaultText can be used to avoid setting many nodes explicitly to the same start value.
  • Virtual Treeview's column implementation also allows fixed columns, making it a good grid replacement too.
Newest technologies

  • For smooth animations (e.g. hint fading) Virtual Treeview uses hand optimized MMX assembler routines. This code is also used to draw the translucent selection rectangle in multi selection mode. This is very much like what Windows 2000 and Windows XP support but works also on Windows 95/98/Me.
  • An alpha blended image of the tree window is shown while doing drag and drop. On Windows 2000 and Windows XP IDropTargetHelper and IDragSourceHelper interfaces are supported which allow for some very neat effects (as used by Explorer). On older consumer Windows versions the drag image is simulated by the tree but underlies there some minor limitations.
  • Virtual Treeview supports Windows XP themes. It acts properly on theme changes and uses for all visual elements which are themed the correct image by using native APIs. Under other Windows systems these styles are supported by separate legacy code. Theme awareness can be switched.
Unicode
  • TVirtualStringTree is implemented using Unicode/wide strings exclusively.
  • The tree saves and reads all Unicode properties (e.g. column captions, default node text and the like) correctly to/from DFM.
  • All Unicode drawing fully supports bidirectionality (i.e. right-to-left drawing), column alignment (left, center, right) and correctly aligned hints. Of course also this feature is available on Windows 95/98/Me.
Drag'n drop and clipboard support
  • OLE drag and drop and OLE clipboard transfers are supported with the tree as source and target. Alternatively, VCL drag'n drop can still be used for compatibility.

    These formats are support by the standard implementation:
    • Native serialized format (CF_VIRTUALTREE and CF_VTREFERENCE), which is a compact form to exchange data between Virtual Treeviews (also between applications). Two storage formats are available: HGlobal and IStream.
    • Plain ANSI text string format.
    • Plain Unicode text string format.
    • Rich Text (RTF) string format (with Unicode text).
    • HTML text string format (UTF-8). This is the preferred clipboard format for Word 2000 etc. and allows copy and paste tree content to a word document with nearly no application code.

    There is a registration scheme (RegisterVTClipboardFormat) which allows descendants to specify and implement their own clipboard formats. Via a drop handler the application can accept any OLE format without deriving an own tree class. In order to aid processing of the native tree data specialized methods are implemented. See also: TBaseVirtualTree.ProcessOLEData and TBaseVirtualTree.ProcessDrop.
  • Dropmarks show during drag'n drop where data will be inserted. This works also with VCL drag'n drop. The drop target model has been extended to allow drop actions above, below or on a node. Meanwhile vendors of other treeview controls have started using this little but powerfull idea too.
  • Auto expand of nodes which are the drop target for more than an adjustable time interval is performed if enabled.
Header and columns
  • Multiple columns are supported by an own header implementation. This header takes up space in the non-client area of the tree control and supports various buttons styles (standard listview thick buttons, flat buttons, plates, Windows XP style and owner draw).
  • Columns can appear in every order in the tree window.
  • Each column can be hidden including the main column which holds the actual tree.
  • Each column can become the main column.
  • Columns can be shown also without the header.
  • Columns can have various options (visible, clickable, resizable, draggable etc.).
  • You can set individual alignments for each column as well as right-to-left or left-to-right directionality (again: available also on non-middle-east and older Windows consumer systems).
  • Each column can have an own color.
  • The header as well as the columns collection class and the actual column classes support streaming. This is independant from the treeview streaming.
Check support
  • Each node in the tree can have its own check type. This can either be check box (also tristate), radio button or node button. These types can freely be mixed so you can for instance have a node with 10 nodes of which 5 comprise a radio group (where only one of these 5 nodes can be checked) and the other 5 nodes can have a check box (or no check type at all).
  • Mixed (tri-state) check boxes with proper handling for partial checking of child nodes are supported (as often used in install and backup programs).
  • Automatic state change propagation for mixed check button type is possible (if enabled).
  • Check events OnChecking and OnCheck events are supplied too.
  • For special purposes a small flat button can be used, which is called a node button.
  • 7 different kinds of check images are possible. Dark and light check marks, dark and light tick marks, flat check images, Windows XP style check images and application defined check images. For an overview see property TBaseVirtualTree.CheckImageKind.
Design time
  • Virtual Treeview's properties and methods are registered with Delphi categories (Delphi 5 and BCB 5 or higher).
  • A special property editor for the clipboard formats is included which allows a simple format choice. This is particularly important since the available clipboard formats must be given as strings and it is also quite handy to have a list of available formats, even if they are not enabled yet (to know what can be enabled).
Customization
Tree as grid
  • Custom draw and paint cycles are supported via paint events (for the entire tree and for each node).
  • Apart from the built-in check types a user defined check image can be used which is supported by a separate image list (TBaseVirtualTree.CustomCheckImages).
  • Each button in the header can be drawn individually.
  • Three different lines styles are available: dotted lines, solid lines and application defined lines.
  • Applications and descendants can provide their own node editor (which has not necessarily to be a single control) by handling the TBaseVirtualTree.OnCreateEditor event or overriding TBaseVirtualTree.DoCreateEditor. This allows to completely replace node editing by own (business) rules.
  • Applications and descendants can provide their own drag manager interface by handling the TBaseVirtualTree.OnCreateDragManager event or overriding TBaseVirtualTree.DoCreateDragManager. This allows to customize the entire OLE drag handling of the tree. Note: VCL drag'n drop is managed by the VCL so this cannot be customized.
  • Applications and descendants can provide their own data object interface by handling the TBaseVirtualTree.OnCreateDataObject event or overriding TBaseVirtualTree.DoCreateDataObject. This allows to provide own clipboard formats.
  • There is a registration function (RegisterVTClipboardFormat), which allows to register tree descendants with own clipboard and/or storage formats. Applications can provide own clipboard formats (without deriving new tree classes) by handling the TBaseVirtualTree.GetUserClipboardFormats event.
  • Applications and descendants can completely modify the tree's key handling by handling the TBaseVirtualTree.OnKeyAction event or overriding TBaseVirtualTree.DoKeyAction. This works also for incremental search.
  • Applications and descendants can customize the tree's background which is not covered by nodes, by handling the TBaseVirtualTree.OnPaintbackground event or overriding TBaseVirtualTree.DoPaintbackground. For nodes there are further events for customization.
  • Applications and descendants can customize how the string tree shortens too long captions by handling the TCustomVirtualStringTree.OnShortenString event or overriding TCustomVirtualStringTree.DoShortenString.
Scrolling
  • Flat scroll bars are supported. but since they conflict with Windows XP this support is switched off by a compiler symbol (UseFlatScrollbars). Enable this symbol if you really want to use flat scroll bars before compiling the tree unit.
  • Every scroll operation triggers an TBaseVirtualTree.OnScroll event. This allows to synchronize trees with other controls.
  • There are properties (e.g. TBaseVirtualTree.OffsetXY) which allow to scroll the tree content to any postion in code without sending messages around.
  • Wheel panning and scrolling is supported. That is, when clicking the mouse wheel or pressing and holding it while moving the mouse around the tree window is scroll smoothly.
Streaming
  • Sophisticated tree content serialization has been implemented to allow saving and restoring a tree to/from streams. This includes also user data as long as it can be written to a stream.
  • Virtual Treeview allows also to add data from stream instead replacing the entire content.
  • The internal format of the stream is chunk based which makes it very flexible for future enhancements but still keeps compatibility with older implementations.
  • There is a user chunk which takes data written to the stream in the TBaseVirtualTree.OnSaveNode event. The data of this user chunk is can be read in TBaseVirtualTree.OnLoadNode.
Developer support
  • Special care has been taken to format the source code of Virtual Treeview consistently.
  • A large part of the entire implementation are comments which describe the inner workings.
  • Methods and properties are consequently ordered alphabetically within their scope (private, protected, public, published). The only exception are the constructors and destructors which always appear at the top of the public section in the class declaration and are always the first methods in the class implementation.
  • For every event there is a virtual method which calls the event handler. This allows descendants to get notice of every event without assigning a handler. The names of these methods correspond directly to the events by using the pattern: DoEventName.
  • Many measures have been taken to ensure borland C++ builder compatibility. This is particularly difficult because the automatic translation from Delphi to C++ code in BCB is buggy.
  • There is an easy and powerfull mechanism for descendants writers to allocate their own data on a per node basis. Simply call TBaseVirtualTree.AllocateInternalData to register your needs. This will not influence existing or future application code if it consequently uses TBaseVirtualTree.GetNodeData for user data access.
Editing
  • Application defined editors are supported via an edit link interface. A generic (non-Unicode) editor implementation is available too.
  • Every column in the tree is editable if enabled (see TCustomVirtualTreeOptions.SelectionOptions.toExtendedFocus).
Utilities
For your convenience some of the internally used functions which are of general interest are exposed.
  • Alphablend: a general purpose procedure to blend a source onto a target bitmap using several different modes.
  • DrawTextW: a partial implementation of the DrawText API which supports Unicode. This method only has a stub on Windows 95/98/Me.
  • ShortenString: a general purpose function which makes a given WideString fitting into a given space. This is partially implemented by the Windows DrawText API but takes additionally care for right-to-left alignment and works with Unicode also on Windows 95/98/ME.

* Times given here are taken on a Windws XP professional system running on an Athlon 650 MHz with 256Mb RAM. All possible optimization were applied.

Downloads:

Main Virtual Treeview package
Version: 5.2.2 Last change: 05. Jan 2014
Download count: 2519556 Size: 3,297 KB
Author: VT team Website: www.soft-gems.net
Platform: Delphi 7, 2006, 2007, CB 2010, BDS 2006-RAD Studio XE3 Type of download: Delphi component
Virtual Treeview help in Adobe postscript format.
Version: n/a Last change: 03. Feb 2007
Download count: 731631 Size: 7,976 KB
Author: Mike Lischke Website: www.soft-gems.net
Platform: Any platform / OS Type of download: Adobe pdf file
A collection of compiled demos showing various aspects of Virtual Treeview. The source for these demos are in the source code repository. Note: these demos were compiled with an older version of VT. Use the source code to compile current binaries.
Version: n/a Last change: 03. Feb 2007
Download count: 453050 Size: 4,790 KB
Author: Mike Lischke Website: www.soft-gems.net
Platform: Windows 9x / Me, Windows NT / 2K / XP Type of download: Application
Additional contributions for Virtual Treeview containing demos or descendants.
Version: n/a Last change: 03. Feb 2007
Download count: 267691 Size: 6,278 KB
Author: Website:
Platform: Delphi 5 - 6, BCB 5 - 6 Type of download: Delphi source + demo
Virtual Treeview help in separated HTML pages.
Version: n/a Last change: 03. Feb 2007
Download count: 140012 Size: 3,323 KB
Author: Mike Lischke Website: www.soft-gems.net
Platform: Any platform / OS Type of download: Plain HTML help
5715 email postings from the old Yahoo Groups mailing list for Virtual Treeview compiled into chm help file. Navigation is a bit ugly but full text search works well.
Version: n/a Last change: 03. Feb 2007
Download count: 127815 Size: 4,695 KB
Author: Miha Remec Website: www.miharemec.com
Platform: Windows 9x / Me, Windows NT / 2K / XP Type of download: Compiled HTML help (CHM)
Archived Virtual Treeview package
Version: 4.8.7 Last change: 30. Oct 2010
Download count: 97196 Size: 1,186 KB
Author: Mike Lischke Website: www.soft-gems.net
Platform: Delphi 6-7, 2005, 2007, BCB 4-6, BDS 2006-2009 Type of download: Delphi component
A collection of demos and VT descendants contributed by different people.
Version: n/a Last change: 03. Feb 2007
Download count: 95461 Size: 70 KB
Author: Multiple authors Website:
Platform: Delphi 6 Type of download: Delphi component
Extensive demo application with source code, which shows various aspects of Virtual Treeview in a clear, easy to understand way.
Version: n/a Last change: 03. Feb 2007
Download count: 88627 Size: 575 KB
Author: Tom Conlon Website: www.2LS.com
Platform: Delphi 5 - 7 Type of download: Delphi source + demo
This demos shows how Virtual Treeview can work with databases. It demonstrates in detail every aspect of this non-trivial task including sorting.
Version: n/a Last change: 03. Feb 2007
Download count: 68474 Size: 5 KB
Author: Allen O'Neill Website: www.springboardtechnologies.com
Platform: Delphi 5 - 7 Type of download: Delphi source + demo
Contains a collection of editors for Virtual Treeview.
Version: n/a Last change: 03. Feb 2007
Download count: 59720 Size: 14 KB
Author: Kostas Giannakopoulos Website:
Platform: Delphi 4 - 6, BCB 4 - 6 Type of download: Delphi component
Sample implementation of an XML visualization tree using Virtual Treeview as base.
Version: n/a Last change: 03. Feb 2007
Download count: 57365 Size: 19 KB
Author: Franckenstein/Arledge Website:
Platform: Delphi 5 - 7 Type of download: Delphi component
Demo showing the application of Virtual Treeview as a property editor.
Version: 2.0 Last change: 26. Aug 2008
Download count: 56714 Size: 335 KB
Author: Tomasz Trejderowski Website:
Platform: Delphi 5 - 6 Type of download: Delphi component
English translation of the german VT tutorial written by Phillip Frenzel (PDF)
Version: n/a Last change: 03. Feb 2007
Download count: 48849 Size: 220 KB
Author: Koos de Graaf Website:
Platform: Any platform / OS Type of download: Adobe pdf file
Demo application with source code showing a Virtual Treeview descendant capable of managing *.ini files.
Version: n/a Last change: 03. Feb 2007
Download count: 45670 Size: 472 KB
Author: Wim van der Vegt Website:
Platform: Delphi 4 - 6, BCB 4 - 6 Type of download: Delphi source + demo + help
A Virtual Treeview descendant showing a way to have nested headers.
Version: n/a Last change: 08. Sep 2012
Download count: 36631 Size: 341 KB
Author: Wim van der Vegt Website:
Platform: Delphi 5 - 6 Type of download: Delphi source + demo + help
This little nice Virtual Treeview descendant implements a non-client-area footer very similar to the header in the treeview. Only very few code is necessary to accomplish this.
Version: n/a Last change: 03. Feb 2007
Download count: 25628 Size: 7 KB
Author: Cyril Velter Website:
Platform: Delphi 5 - 7, BCB 5 - 6 Type of download: Delphi component
Demo showing how to use IVTEditLink in Delphi 5.
Version: n/a Last change: 03. Feb 2007
Download count: 25082 Size: 388 KB
Author: Roland Beduerftig Website: www.softwarecreation.de
Platform: Borland C++ Builder 5 Type of download: Delphi source + demo
English translation of the german VT tutorial written by Phillip Frenzel (HTML)
Version: n/a Last change: 03. Feb 2007
Download count: 23696 Size: 121 KB
Author: Koos de Graaf Website:
Platform: Any platform / OS Type of download: Plain HTML help
Demo showing how to use application data in Virtual Treeview.
Version: n/a Last change: 03. Feb 2007
Download count: 23614 Size: 6 KB
Author: Sasa Zeman Website: www.szutils.net
Platform: Delphi 5 - 7 Type of download: Delphi source + demo
A Virtual Treeview descendant with buttons in each cell
Version: n/a Last change: 03. Feb 2007
Download count: 22991 Size: 20 KB
Author: Luis David Cardenas Bucio Website:
Platform: Delphi 5 - 7, BCB 5 - 6 Type of download: Delphi component
A Borland C++ Builder demo showing the use of multi line nodes.
Version: n/a Last change: 03. Feb 2007
Download count: 18760 Size: 265 KB
Author: Sparky Website:
Platform: Borland C++ Builder 5 - 6 Type of download: Borland C++ Builder demo
A first attempt of porting Virtual Treeview to Kylix. Note: not all features are currently available in this port (e.g. drag'n'drop).
Version: 3.5.1 Last change: 03. Feb 2007
Download count: 18665 Size: 270 KB
Author: Dmitri Dimitrienko Website:
Platform: Kylix 1 - 3 Type of download: Delphi component
Archived Virtual Treeview package
Version: 4.5.2 Last change: 05. May 2007
Download count: 12241 Size: 2,995 KB
Author: Mike Lischke Website: www.soft-gems.net
Platform: Delphi 6-7, 2005, 2007, BCB 4-6, BDS 2006-2009 Type of download: Delphi source + demo + help
A small demo application for BCB users showing how to work with the STL and Virtual Treeview.
Version: n/a Last change: 03. Feb 2007
Download count: 10197 Size: 7 KB
Author: Craig Benbow Website:
Platform: Borland C++ Builder 5 - 6 Type of download: Borland C++ Builder demo
Archived Virtual Treeview package
Version: 4.8.5 Last change: 14. Mar 2009
Download count: 9725 Size: 722 KB
Author: Mike Lischke Website: www.soft-gems.net
Platform: Delphi 6-7, 2005, 2007, BCB 4-6, BDS 2006-2009 Type of download: Delphi source + demo + help
Archived Virtual Treeview package
Version: 4.7.0 Last change: 24. Aug 2008
Download count: 8427 Size: 708 KB
Author: Mike Lischke Website: www.soft-gems.net
Platform: Delphi 6-7, 2005, 2007, BCB 4-6, BDS 2006-2009 Type of download: Delphi source + demo + help
Archived Virtual Treeview package
Version: 4.7.0 Last change: 31. Aug 2008
Download count: 7681 Size: 359 KB
Author: Mike Lischke Website: www.soft-gems.net
Platform: Delphi 6-7, 2005, 2007, BCB 4-6, BDS 2006-2009 Type of download: Delphi component
Archived Virtual Treeview package
Version: 4.5.2 Last change: 03. Feb 2007
Download count: 7428 Size: 287 KB
Author: Mike Lischke Website: www.soft-gems.net
Platform: Delphi 6-7, 2005, 2007, BCB 4-6, BDS 2006-2009 Type of download: Delphi component
Archived Virtual Treeview package
Version: 4.8.6 Last change: 07. Sep 2009
Download count: 3535 Size: 711 KB
Author: Mike Lischke Website: www.soft-gems.net
Platform: Delphi 6-7, 2005, 2007, BCB 4-6, BDS 2006-2009 Type of download: Delphi source + demo + help
Archived Virtual Treeview package
Version: 4.8.5 Last change: 15. Mar 2009
Download count: 3357 Size: 347 KB
Author: Mike Lischke Website: www.soft-gems.net
Platform: Delphi 6-7, 2005, 2007, BCB 4-6, BDS 2006-2009 Type of download: Delphi component
Archived Virtual Treeview package
Version: 4.8.7 Last change: 21. Nov 2010
Download count: 2817 Size: 719 KB
Author: Mike Lischke Website: www.soft-gems.net
Platform: Delphi 6-7, 2005, 2007, BCB 4-6, BDS 2006-2009 Type of download: Delphi source + demo + help

Google Code

For collaborative development I use Google Code since a while. At the time being only Virtual Treeview is hosted there.

Donate

Writing Open Source software has costs (for the server, domains etc.). So if you think my work is worth a donation to support further development then don't hesitate. Either do a single time donation via Paypal

or a repeating donation via Git Tip (use my GitHub account mike-lischke).

Forums Registrations

If you want to register in the Soft Gems forums please do so but additionally send me an e-mail, so I can activate your account. This countermeasure is necessary to fight spammers.

The VIP code to use for registration is 33209.