spacer spacer spacer spacer spacer spacer spacer spacer
Luigi Bianchi Web Site spacer
spacer Home Software Programming Others About spacer spacer
spacer spacer
spacer spacer

www.luigibianchi.com

Dfm2API/DfmTranslator UtilitiesC/C++ Users Jounal Cover Page

separator images

A VCL Form Converter

This page deals with to the free Dfm2API utility (and the shareware DfmTranslator) that have been published in the August 2000 issue of C/C++ Users Journal. It is my desire to extend its capabilities and to fix all the tons of bugs that you’ll find over the time. So I need your feedback: suggestions, improvements, critics and even money!


What’s this utility for?

Embarcadero C++ Builder and Delphi (previously from Borland and CodeGear) define a resource file format (DFM) that cannot be used in non-VCL applications. Dfm2API is a free tool that converts a Borland DFM resource file into a standard Windows RC (resource script) file and a CPP and HPP file with Windows API calls to replicate the behaviour of the VCL form without writing a single line of code! Another tool, the DfmTranslator, which is similar to Dfm2API and can be obtained with a small fee, allows you to customize the way in which the translation is done allowing you to support different GUI frameworks, different languages, and different compilers! Because a DFM file contains also a lot of information about controls initializations (e.g. you can specify which strings appears in a combobox without writing code), this utility extracts them and then automatically writes the required code in a CPP file so that you can use these RAD facilities in non-VCL applications! This utility can also operate on binary files (EXEs, DLLs, etc) extracting DFM resources (i.e. menu, images, etc) and replicating the appearence of each contained form!

What are the differences between Dfm2API and DfmTranslator?

The Dfm2API tool is free and and is the evolution of the original utility. Two dictionaries are available to convert the VCL forms into standard API calls and the OWLNext framework.

The DfmTranslator tool is shareware (try before buy for 39 euros/49$). You are allowed to add new dictionaries (e.g. to convert to C#, Javascript, wxWidgets, MFC, etc...) that you can write by yourself and you can modify existing dictionaries according to your style.

Who can benefit from it?

Everybody!!!! Well, that’s not true, but all the people that need a resource script file (both Delphi and C++ Builder users) or that wants to build WinAPI, MFC, or OWL applications could benefit from Dfm2Api/DfmTranslator tools. The main advantages are:

  • Dramatically Smaller executable size (more than one order of magnitude!);
  • Shorter compile and link time;
  • Shorterbuild time;
  • Compatibility with every C/C++ compiler;
  • Generated Resources are compatible with MFC, OWLNext, wxWidgets, SDK, etc..
  • No need for additional DLLs;
  • No dependence on framework release; That means that you don't have to buy/wait for component new releases;

You canuse C++ Builder/Delphi for prototyping, and then translate the VCL Forms into standard resources. This reduces considerably Development time (through RAD facilities), executable size and compile time.

What this utility does NOT do today?

It does not convert non-standard windows controls. It is still possible, anyway, to treat a specific control as another one: for example a THighlyEnhancedAndWonderfulRadioButtonWithFireWorks can be treated as a simple TRadioButton, but the HighlyEnhancedAndWonderfulFireWorks capabilities will be lost. A special configuration file is provided to perform and customize this conversion task. So, it is still possible to convert a TBDEdit into an EditBox, but in that case you’ll lose all the RAD DB facilities and you’ll have to write the code to implement the required DB queries, etc.. It does not (yet) convert TPropertyPages and events (such as OnClick). This functionalities will be added in future releases.

What are the supported controls?

Actually, you can convert the following components into one of the following controls/resources/common dialogs (red one are the latest updates):

  Component Release History
Controls
1 Animate   1.2

1.0 With data initialization 
1.2.2 Added transparent color property

2 Bevel     1.0 1.0 Supported through WM_PAINT message
3 BitBtn    1.0 1.0 It does not exist a standard Glyph Button control. Will be substituted with an Uncommon Control
4 Button    1.0 1.0 With data initialization 
5 CheckBox  1.0 1.0 With data initialization
6 ComboBox 

1.1

1.0 With data initialization
1.1 Better "height" property handling
7 DateTimePicker 1.2.2

1.0 With data initialization (partial)  
1.2.2 Improved data initialization

8 Edit      1.0 1.0 With data initialization
9 GroupBox  1.0 1.0 With data initialization 
10 Header    1.1 1.0 With data initialization (partial)
1.1 Better "width" property handling and added "Alignment" support
11 HotKey    1.0 1.0 Only Resource Script File   
12 Image     1.2.2 1.0 With data initialization (partial)  
1.2.2 Added Stretch property (processed through WM_PAINT message)
1.2.2 Added transparencies (white color mapped to transparent)
13 ImageList 1.2

1.1 I have finally discovered how the data are stored!!! Coming soon!!!!
1.1.1 beta (build 131) Images are extracted!!
1.2 ImageLists are created and used in TreeViews! All the images are stored as 256 color images, even if they are extracted as Icons too.

14 Label     1.0 1.0 With data initialization
15 ListBox   1.1 1.0 With data initialization
1.1 Better "height" property handling
16 ListView  1.2

1.0 With data initialization (partial: columns text but not items text)
1.1 Still partial, but better "width" property handling and added "Alignment" support
1.1.1 (build 111) Added item text initialization
1.2 Added (simplified) ImageList support!!

17 Memo      1.0 1.0 With data initialization
18 MonthCalendar 1.2.2 1.0 With data initialization (partial)
1.2.2 Improved data initialization
19 PageControl 0.0 OK, sooner or later I will do it! I've received so many E-Mails asking for it, that now I know that I MUST do it.
20 Panel     1.0 1.0 With data initialization 
21 ProgressBar 1.0 1.0 With data initialization
22 RadioButton 1.0 1.0 With data initialization
23 RadioGroup 1.0 1.0 With data initialization
24 RichEdit  1.0 1.0 With data initialization
25 ScrollBar 1.2.2 1.0 With data initialization 
1.2.2 Improved data initialization (range and border)
26 SpeedButton 1.0 1.0 With data initialization 
27 SpinEdit  1.0 1.0 With data initialization
28 StatusBar 1.0 1.0 With data initialization (partial)
1.1.1 Fixed bug with "deleted" panels
29 ToolBar   1.0 1.0 Only Resource Script File 
30 TabControl 1.2.2 1.0 With data initialization (partial)
1.2 Added (simplified) ImageList support!!
1.2.2 Improved tab size
31 TrackBar  1.2.2 1.0 With data initialization
1.2.2 Improved (ThumbLength, Line and Page properties handling added)
32 TreeView  1.2

1.0 Only Resource Script File 
1.1.1 (build 111) Improved RC caps, added item text initialization
1.2 Added (simplified) ImageList support!!

33 UpDown    1.0 1.0 With data initialization (partial)
1.1.1 (build 111) New bug added!! (Fixed in next release). Will cause wrong alignment.
Menus
34 MenuItem  1.0 1.0 With "response table"
35 MainMenu  1.0 1.0 With "response table" 
36 PopupMenu 1.0 1.0 With "response table" 
Common Dialogs
37 FontDialog 1.0 1.0 With data initialization (partial)
In progress:LogFont data initialization
38 FindDialog 1.1 1.0 With data initialization (partial)
1.1 With complete data initialization
39 ReplaceDialog 1.1 1.0 With data initialization (partial)
1.1 With complete data initialization
40 ColorDialog 1.1 1.0 With data initialization (partial)
1.1 With improved data initialization
41 OpenDialog 1.1 1.0 With data initialization (partial)
1.1 With complete data initialization
42 SaveDialog 1.1 1.0 With data initialization (partial)
1.1 With complete data initialization


Note that not all the properties are converted into resources/ line of code, but I think that the most important ones are treated.

How does it work?

Imagine that you need to design a DialogBox for a WinAPI application. What you have to do is simply to design it as a VCL Form, and then convert it with the Dfm2APIutility: select the destination framework (SDK API calls or OWLNext with the Dfm2API tool or whatever you want with the DfmTranslator tool). You will obtain a .RC file, that is (more or less) exactly what you need (a resource script file, defined at the OS level), a .CPP and .HPP file. The .RC file contains all the statements that are required to generate a .RES file that can be linked to a Win32/Win64 module, while the .CPP and .HPP files are responsible to create the proper DIALOGPROC and to initialize the controls that populates the DialogBox. You can see an example here.

Example

If you design a form like the following one with C++ Builder (executable size is 1,588KB):

Original VCL Form


and then you convert it with Dfm2API (target, API calls), you will obtain the following DialogBox (executable size is only 105KB!):

SDK converted form

Click here to give a look at the automatically generated source code file from the proviously described Form.

or if you converte it to OWLNext, you'll get this one (executable size is 1,073KB):

OWLNext converted form

Click here to give a look at the automatically generated source code file from the proviously described Form.

As you can see, even if there are small differences, they are quite similar. Also a lot of controls are initialized, with no need to write code, because Dfm2API did it for you.

History

Version
Build
Date
Description
1.4.5
230
28 May 2013
Added support to OWLNext targets for both the free Dfm2API and the DfmTranslator
1.4.4
219
17 January 2013
Completely rewritten! Now there are two version: Dfm2API, which is still free and DfmTranslator (shareware) which allows you to customize the translation and to add new dictionaries to target new frameworks/compilers (e.g. JavaScript, GCC, FireMonkey, etc...)
1.2.2
164
28 September 2001
Partially updated the engine to support more features. Improved Animate, Image, DateTimePicker and MonthCalendar controls. Fixed Form automatic resizing. It's a minor release, but I wanted to give the idea that I'm still working on it. As I've done some changes to the engine, let's consider it a release candidate (more than a beta). There are some menu items that are disabled because I'm still working on them. Anyway, there are some interesting new features that someone asked me, so I decided to release it.
1.2.1
160
10 May 2001
Fixed minor bugs, improved (not completed) compatibility with VisualC and Windows CE. Improved UNICODE support.
1.2.0
153
17 January 2001
Fixed minor bugs, support for ImageLists in TreeViews, ListViews and TabControls.
Improved ListView and TreeView behavior. Fixed minor bug with TStatusBar.
New user interface (it's just the beginning). Added preview window for some controls.
Improved Form automatic resizing options
1.1
65
28 December 2000
Added support for C++ Builder 5 and Delphi 5. Improved support for Common Dialogs. Minor changes. I'm actually debugging a major upgrade. I hope to have time to release it in late January.
1.0 
1
1 August 2000

Released with source code to C/C++ Users Journal.

Downloads

The project with the source code relative to release 1.0 is available at CUJ site.
You can download the main releases here.

 

 

© Copyright (2000-2013), Luigi Bianchi
Last Update: May 28, 2013