Converting from VCL to FireMonkey
Go Up to FireMonkey Applications Guide
Differences Between VCL and FireMonkey Applications
The VCL (Visual Component Library) supports only Windows-based development—both the Win32 and the Win64 platforms. FireMonkey components, on the other hand, have been customized for use on all the supported platforms, including the OS X (Mac) platform.
FireMonkey is somewhat similar to the VCL library; FireMonkey and VCL share ancestry from TObject to TComponent, but they diverge beyond TComponent. If you are familiar with the VCL, some of the classes, components, controls, and functions in FireMonkey will be familiar. However, FireMonkey is a new framework that offers vector-based dynamic controls, and other features that the VCL does not offer. For example, FireMonkey has sophisticated 2D and 3D graphics, and special effects such as filters.
Migrating VCL Applications to FireMonkey
Although there is no direct migration path between the VCL and FireMonkey, you can convert an existing VCL application by creating a new HD Multi-Device Application, then modifying-cutting-pasting the existing VCL application, essentially refactoring the VCL application so that it is a FireMonkey application, which can run cross-platform.
Using the Mida Converter to Convert a VCL Application to FireMonkey
The Mida Converter is a third-party product that automates some aspects of converting VCL controls into FireMonkey controls. Mida installs as a plug-in to the Tools menu in the RAD Studio IDE.
Several versions of Mida are available:
- The free version of Mida migrates standard VCL controls and LiveBindings.
- For the free version, see http://cc.embarcadero.com/item/29443
- The Mida Pro and Mida Studio versions offer enhanced functionality, such as conversion of custom controls and images.
The Mida pack enables support for button images like the VCL TBitBtn component.
The Mida home page offers more information, including blogs, FAQs, and product orders: http://www.midaconverter.com/
Commonly Encountered Differences
Although FMX is designed to have some superficial similarity with VCL, numerous small differences can trip up someone that is familiar with VCL. These include, in no particular order:
- In VCL, the position of a control is expressed by its Top and Left properties.
- In FireMonkey, controls use a Position of type TPosition with nested X and Y properties. 3D controls' Position property is an instance of TPosition3D, with an additional Z coordinate. For size, FireMonkey uses Width and Height (and Depth for 3D controls).
- Text: The text that appears in a FireMonkey label is its Text, not its Caption (as in VCL).
- Font Sizes:
- In FireMonkey, font sizes are expressed in device-independent pixels (DIPs), 96 per logical inch.
- In VCL, font sizes are expressed in points, 72 per logical inch.
- Therefore, text using the same Font.Size is smaller in FireMonkey.
- Check Boxes: In FireMonkey, check boxes should use the OnChange event to react to checked-state changes instead of OnClick. The property that reflects that state is IsChecked, not Checked as in VCL.
- Colors: FireMonkey colors have an alpha (opacity) component in addition to RGB. Colors are represented by system types TAlphaColor and TAlphaColorRec. FireMonkey uses color constants from the System.UIConsts unit. These color constants are prefixed with "cla" instead of "cl". Also see Colors in VCL.
- Radio Buttons and Groups:
- In order to convert the VCL TRadioGroup to FireMonkey, you can use either TPanel or TGroupBox.
- TGroupBox: The radio buttons in each VCL TGroupBox are independent. If you convert multiple VCL TGroupBox to FireMonkey TGroupBox, the containing radio buttons become dependant (selection in one group clear selection in other groups). To restore independence in FireMonkey, manually specify GroupName property for each converted TRadioButton.
- Child-Parent Relationship: In VCL, objects parenting other components can be done only through TForms, TFrames, TPanels and Data Modules. In FireMonkey, you can parent any object to anything else, and this relationship can be easily established in the Structure View.
- A TMaskEdit or a TEdit in VCL can be implemented in FireMonkey using a TEdit and its Password property.
- Events: The VCL events OnDrawDataCell or OnDrawColumnCell can be replaced in FireMonkey with TStringGrid with LiveBindings.
- Constants: Constants like modal results and virtual key codes have moved from Vcl.Controls to System.UITypes.