Overview
TeeTree’s VCL (Visual Component Library) version provides full support for Windows desktop applications using native VCL components and controls. The VCL framework offers optimal performance and native Windows integration.
Installation
Unit References
For VCL applications, include the following units in your uses clause:
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, TeeProcs, TeeTree, TreeEd;
Component Placement
Add the TTree component to your VCL form:
Open the Tool Palette in Delphi IDE
Navigate to the TeeTree tab
Drag TTree component onto your form
Set properties in the Object Inspector
Key VCL Features
Native Windows Controls
The VCL version uses native Windows GDI/GDI+ for rendering, providing:
Fast rendering with hardware acceleration
Native scrollbars (TWinControl-based)
Standard Windows messages for mouse/keyboard input
ImageList integration for node icons
Print preview using VCL’s TPrinter
VCL-Specific Constants
const
TeeDefaultBoxSize = 4 ; // VCL uses smaller default
crArrowRight = TCursor( 2021 ); // Custom VCL cursors
crArrowDown = TCursor( 2022 );
Creating Your First VCL Tree
Using the Designer
Drop a TTree component on your form
Right-click and select Edit Tree to open the designer
Add nodes using the toolbar buttons
Configure node properties in the Object Inspector
Set up connections between nodes by dragging
Programmatic Creation procedure TForm1.FormCreate (Sender: TObject);
var
RootNode, ChildNode: TTreeNodeShape;
begin
// Add root node
RootNode := Tree1. Add ( 'Root Node' );
// Add child nodes
ChildNode := RootNode.AddChild( 'Child 1' );
RootNode.AddChild( 'Child 2' );
RootNode.AddChild( 'Child 3' );
// Expand the root
RootNode.Expanded := True ;
// Select first child
ChildNode.Selected := True ;
// Focus the tree
Tree1.SetFocus;
end ;
Working with Node Images
Using ImageList
VCL ImageList Integration
Built-in Images
procedure TForm1.SetupImages ;
begin
// Assign ImageList to Tree
Tree1.Images := ImageList1;
// Set image index for nodes
Tree1.Roots[ 0 ].ImageListIndex := 0 ; // Folder icon
Tree1.Roots[ 0 ].Children[ 0 ].ImageListIndex := 1 ; // File icon
end ;
VCL-Specific Properties
Canvas and Drawing
The VCL version uses TCanvas for all drawing operations:
procedure TForm1.Tree1CustomDraw (Sender: TObject);
var
R: TRect;
begin
with Tree1.Canvas do
begin
Brush.Color := clWhite;
Pen.Color := clBlack;
Pen.Width := 1 ;
// Custom drawing here
Rectangle( 10 , 10 , 100 , 100 );
end ;
end ;
VCL scrollbars are standard Windows controls:
procedure TForm1.ConfigureScrollbars ;
begin
Tree1.HorzScrollBar.Automatic := True ;
Tree1.HorzScrollBar.Visible := True ;
Tree1.VertScrollBar.Automatic := True ;
Tree1.VertScrollBar.Visible := True ;
// Flat style (Windows theme)
Tree1.HorzScrollBar.Flat := True ;
Tree1.VertScrollBar.Flat := True ;
end ;
Printing Support
Print Preview
VCL provides full printing capabilities:
uses
Printers;
procedure TForm1.PrintTree ;
begin
with Tree1 do
begin
PrintPreview;
// or
Print;
end ;
end ;
procedure TForm1.ConfigurePrintOptions ;
begin
Tree1.PrintOptions.Orientation := poLandscape;
Tree1.PrintOptions.Margins.Left := 10 ;
Tree1.PrintOptions.Margins.Top := 10 ;
end ;
Event Handling
Standard VCL Events
procedure TForm1.Tree1ClickShape (Sender: TTreeNodeShape;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer );
begin
// Handle node click
ShowMessage( 'Clicked: ' + Sender.Text[ 0 ]);
end ;
procedure TForm1.Tree1SelectShape (Sender: TTreeNodeShape);
begin
// Update status bar
StatusBar1.SimpleText := 'Selected: ' + Sender.Text[ 0 ];
end ;
procedure TForm1.Tree1MouseMove (Sender: TObject; Shift: TShiftState;
X, Y: Integer );
var
Node: TTreeNodeShape;
begin
// Show hint on mouse over
Node := Tree1.Shapes.Clicked(X, Y);
if Assigned(Node) then
Tree1.Hint := Node.Text[ 0 ];
end ;
Database Integration
DBTree Component
VCL includes the TDBTree component for automatic database binding:
procedure TForm1.SetupDBTree ;
begin
// Connect to dataset
DBTree1.DataSource := DataSource1;
// Map fields
DBTree1.MasterField := 'ParentID' ;
DBTree1.DetailField := 'ID' ;
DBTree1.TextField := 'Name' ;
DBTree1.IconField := 'IconIndex' ;
// Populate from database
DBTree1.Active := True ;
end ;
Large Trees in VCL
For optimal performance with thousands of nodes:
Disable AutoSize on nodes
Use BeginUpdate/EndUpdate when adding multiple nodes
Set appropriate TreeListCapacity values
procedure TForm1.AddManyNodes ;
var
I: Integer ;
begin
// Increase capacity for better performance
TreeListCapacity := 1000 ;
TreeShapeListCapacity := 1000 ;
Tree1.BeginUpdate;
try
for I := 0 to 999 do
Tree1. Add ( 'Node ' + IntToStr(I));
finally
Tree1.EndUpdate;
end ;
end ;
Advanced Features
Custom Node Shapes
type
TMyCustomShape = class (TTreeNodeShape)
protected
procedure DrawShapeCanvas ( const ACanvas: TCanvas3D;
const R: TRect); override ;
end ;
procedure TMyCustomShape.DrawShapeCanvas ( const ACanvas: TCanvas3D;
const R: TRect);
begin
// Custom drawing code
ACanvas.Pen.Color := clRed;
ACanvas.Ellipse(R);
end ;
Clipboard Operations
procedure TForm1.CopyToClipboard ;
begin
Tree1.CopyToClipboardMetafile;
// or
Tree1.CopyToClipboardBitmap;
end ;
procedure TForm1.PasteFromClipboard ;
begin
if Tree1.CanPaste then
Tree1.Paste;
end ;
Styling and Themes
Windows Visual Styles
procedure TForm1.ApplyVCLStyles ;
begin
// Enable Windows themes
Tree1.ParentColor := False ;
Tree1.Color := clWindow;
// Flat scrollbars (themed)
Tree1.HorzScrollBar.Flat := True ;
Tree1.VertScrollBar.Flat := True ;
// Border style
Tree1.BevelOuter := bvLowered;
Tree1.BevelInner := bvNone;
end ;
Compatibility
VCL applications are Windows-only. For cross-platform development, use the FMX version instead.
Supported Delphi Versions
Delphi 5 through RAD Studio 13.0 Florence (2025)
C++ Builder (all VCL versions)
Both 32-bit and 64-bit Windows targets
Common VCL Patterns
TreeView Replacement
procedure TForm1.MigrateFromTreeView ;
var
TVNode: TTreeNode;
TreeNode: TTreeNodeShape;
begin
// TreeView compatibility mode
Tree1.GlobalFormat.ChildManager := TTreeExplorerAlignChild;
// Similar API to TTreeView
TreeNode := Tree1. Add ( 'Item' );
TreeNode.AddChild( 'SubItem' );
TreeNode.Expanded := True ;
// Access like TreeView
ShowMessage(Tree1.Roots[ 0 ].Text[ 0 ]);
end ;
See Also