[All]
Converting Applications from VCL to FireMonkey
By: Tim DelChiaro
Abstract: How to convert VCL Windows applications to cross-platform FireMonkey applications
As you may have seen, you can get the Mida Basic edition free with purchase of RAD Studio XE3, Delphi XE3 or C++Builder XE3 until September 28, 2012 as part of the RAD XE3 Bonus Pack.
The Mida Converter can save you a lot of time and often get you most of the way from a VCL application to a FireMonkey application automatically. Other Mida editions are also available that convert an even larger percentage of your applications. This article includes some info on Mida as well as other things to keep in mind when converting applications from VCL to FireMonkey.
The content below comes from the Delphi and C++Builder XE3 online documentation. Links in the article will take you to the RAD Studio doc wiki.
Converting from VCL to FireMonkey
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 FireMonkey 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.
- 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/
Also see Importing or Migrating Existing Projects into XE2 and Migrating VCL Applications to Cross-Platform.
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:
- Standard VCL controls are in the Vcl.StdCtrls unit, while equivalent FireMonkey controls are in FMX.Controls. Both frameworks have extra controls in an ExtCtrls unit (FMX.ExtCtrls and Vcl.ExtCtrls), but with no overlap.
- The position of a VCL control is expressed by its Top and Left properties. 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. FireMonkey uses Width and Height (and Depth) for size.
- The text that appears in a FireMonkey label is its Text, not its Caption (as in VCL).
- Font sizes in FMX are expressed in device-independent pixels (DIPs), 96 per logical inch. Font sizes in VCL are expressed in points, 72 per logical inch. Therefore, text using the same Font.Size is smaller in FireMonkey.
- Checkboxes should use the OnChange event to react to checked-state changes instead of OnClick. The property that reflects that state is named IsChecked, not Checked as in VCL.
- FireMonkey colors have an alpha (opacity) component in addition to RGB. Colors are represented by types TAlphaColor and TAlphaColorRec. Color constants are in FMX.Typesand prefixed with "cla" instead of "cl".
- Other constants like modal results and virtual key codes have moved from Vcl.Controls to System.UITypes.
See Also
Connect with Us