Skip to main content

Overview

Migrating a TeeTree application from VCL to FireMonkey (FMX) enables cross-platform deployment while maintaining most of your existing code. This guide covers the key differences and required changes.

Quick Migration Checklist

1

Update Unit References

Replace VCL units with FMX equivalents
2

Update Color Constants

Change VCL colors to TAlphaColors
3

Update Component Types

Replace VCL controls with FMX controls
4

Handle Platform Differences

Adapt code for mobile and desktop platforms
5

Test on All Platforms

Verify functionality on each target platform

Unit References

Replace VCL Units with FMX

uses
  Windows, Messages, SysUtils, Classes, Graphics, 
  Controls, Forms, Dialogs, ExtCtrls, StdCtrls, 
  Printers, ImgList,
  TeeProcs, TeeTree, TeCanvas, TreeEd;

Key Unit Mappings

VCL UnitFMX UnitNotes
TeeTreeFMXTee.TreeMain tree component
TeeProcsFMXTee.ProcsHelper procedures
TeCanvasFMXTee.CanvasCanvas operations
GraphicsFMX.GraphicsGraphics types
ControlsFMX.ControlsControl base classes
FormsFMX.FormsForm classes
DialogsFMX.DialogsDialog functions
StdCtrlsFMX.StdCtrlsStandard controls
ExtCtrlsFMX.LayoutsPanels become layouts
PrintersFMX.PrinterDesktop only
ImgListN/AUse different approach

Color System Changes

VCL to FMX Color Conversion

procedure TForm1.SetVCLColors;
begin
  Tree1.Color := clWhite;
  Node1.Brush.Color := clBlue;
  Node1.Border.Color := clBlack;
  Node1.Font.Color := clRed;
  
  // Custom color
  Node1.Brush.Color := RGB(255, 128, 0);
end;

Color Constant Mapping

VCL ConstantFMX Constant
clWhiteTAlphaColors.White
clBlackTAlphaColors.Black
clRedTAlphaColors.Red
clBlueTAlphaColors.Blue
clGreenTAlphaColors.Green
clYellowTAlphaColors.Yellow
clGrayTAlphaColors.Gray
clSilverTAlphaColors.Silver
clNavyTAlphaColors.Navy
clNoneTAlphaColors.Null

Component Property Changes

Control Alignment

Tree1.Align := alClient;
Panel1.Align := alTop;
Button1.Align := alBottom;

Bevel Styles

Tree1.BevelOuter := bvLowered;
Tree1.BevelInner := bvNone;
Tree1.BevelWidth := 1;

TeeTree-Specific Changes

No Breaking Changes in Core API

Good news! The core TeeTree API remains virtually identical between VCL and FMX. Most of your tree manipulation code will work without changes.
// This code works identically in both VCL and FMX!
procedure TForm1.CreateTreeStructure;
var
  Root, Child: TTreeNodeShape;
begin
  Root := Tree1.Add('Root');
  Child := Root.AddChild('Child 1');
  Root.AddChild('Child 2');
  Root.AddChild('Child 3');
  
  Root.Expanded := True;
  Child.Selected := True;
  
  // Styling
  Root.Brush.Color := {VCL: clBlue} {FMX: TAlphaColors.Blue};
  Root.Font.Size := 12;
  Root.Border.Width := 2;
end;

Minor Constant Differences

const
  TeeDefaultBoxSize = 4;
  TreeMsg_TeeExtension = 'tte';

Event Handler Signatures

Coordinate Types

FMX uses Single (float) instead of Integer for some coordinates:
procedure TForm1.FormMouseMove(Sender: TObject; 
  Shift: TShiftState; X, Y: Integer);
begin
  // X, Y are Integer
end;

TeeTree Events Remain the Same

// Both VCL and FMX use identical signatures:

procedure TForm1.Tree1ClickShape(Sender: TTreeNodeShape;
  Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
  ShowMessage('Clicked: ' + Sender.Text[0]);
end;

procedure TForm1.Tree1SelectShape(Sender: TTreeNodeShape);
begin
  Caption := 'Selected: ' + Sender.Text[0];
end;

Platform-Specific Code

Conditional Compilation

procedure TForm1.PlatformSpecificFeatures;
begin
  {$IFDEF MSWINDOWS}
  // Windows-specific code (both VCL and FMX)
  Tree1.CopyToClipboardMetafile;
  {$ENDIF}
  
  {$IFDEF FMX}
  // FMX-specific code (all platforms)
  Tree1.Touch.InteractiveGestures := [TInteractiveGesture.Zoom];
  {$ENDIF}
  
  {$IFNDEF FMX}
  // VCL-specific code
  Tree1.PrintPreview;
  {$ENDIF}
  
  {$IF DEFINED(IOS) OR DEFINED(ANDROID)}
  // Mobile platforms
  Tree1.Selected.HandleSize := 10;  // Larger for touch
  {$ENDIF}
end;

Feature Availability Matrix

FeatureVCLFMX WindowsFMX macOSFMX Mobile
Core tree operations
Node styling
Connections
Printing
Clipboard (Bitmap)
Clipboard (Metafile)
ImageList❌*❌*❌*
Touch gestures
Custom cursors⚠️⚠️
Transparency⚠️
GPU acceleration
*Use alternative approaches in FMX

Common Migration Scenarios

Replacing ImageList

procedure TForm1.SetupVCLImages;
begin
  Tree1.Images := ImageList1;
  Node1.ImageListIndex := 0;
  Node2.ImageListIndex := 1;
end;

Printing Code

uses
  Printers;

procedure TForm1.PrintTree;
begin
  Tree1.PrintPreview;
end;

Form Styling

procedure TForm1.SetupVCLForm;
begin
  Color := clBtnFace;
  Font.Name := 'Tahoma';
  Font.Size := 8;
end;

Step-by-Step Migration Process

Step 1: Create FMX Project

// File > New > Multi-Device Application - Delphi
// Choose Blank Application template

Step 2: Copy and Convert Form

  1. Create a new FMX form with the same name
  2. Manually recreate the form layout (cannot directly convert .dfm to .fmx)
  3. Place TTree component from Tool Palette

Step 3: Update Code

// 1. Update uses clause (see above)
// 2. Replace color constants
// 3. Update alignment constants
// 4. Add conditional compilation where needed

Step 4: Test on Multiple Platforms

// Test on each target platform:
// - Windows 32/64
// - macOS
// - iOS (if targeting)
// - Android (if targeting)

Migration Tools

Search and Replace Patterns

FindReplace
clWhiteTAlphaColors.White
clBlackTAlphaColors.Black
clRedTAlphaColors.Red
clBlueTAlphaColors.Blue
clGreenTAlphaColors.Green

Testing Your Migration

Validation Checklist

  • All nodes display correctly
  • Colors appear as expected
  • Fonts scale properly
  • Touch/mouse interaction works
  • Zoom and scroll function
  • Events fire correctly
  • File save/load works
  • Printing works (desktop only)
  • Performance is acceptable
  • Mobile gestures work (if applicable)

Common Issues and Solutions

Issue: Colors Look Different

FMX uses RGBA color space. Ensure you’re using TAlphaColors constants.
// Wrong
Node.Brush.Color := clBlue;  // VCL constant

// Correct
Node.Brush.Color := TAlphaColors.Blue;

Issue: Text Too Small on Mobile

procedure TForm1.FixMobileFonts;
begin
  {$IF DEFINED(IOS) OR DEFINED(ANDROID)}
  Tree1.Font.Size := 16;  // Larger for mobile
  {$ELSE}
  Tree1.Font.Size := 10;  // Desktop size
  {$ENDIF}
end;

Issue: Touch Targets Too Small

procedure TForm1.FixTouchTargets;
begin
  {$IF DEFINED(IOS) OR DEFINED(ANDROID)}
  // Make nodes larger for touch
  Tree1.GlobalFormat.ChildManager.HorizMargin := 30;
  Tree1.GlobalFormat.ChildManager.VertMargin := 20;
  {$ENDIF}
end;

Best Practices

  • Test on all target platforms early and often
  • Use conditional compilation for platform-specific features
  • Design with touch in mind if targeting mobile
  • Keep a VCL version if Windows-only features are critical
  • Use TAlphaColors from the start in new FMX code

When Not to Migrate

Consider keeping VCL if:
  • Application is Windows-only and will remain so
  • Heavy reliance on Windows-specific features
  • Performance is critical (VCL is faster on Windows)
  • Using many third-party VCL-only components
  • Target users are all on Windows desktop

See Also

Build docs developers (and LLMs) love